Source code
Source code
Q10. Write a program to accept a number from the user and check whether it is
prime or not
source code
a=2
b=3
if num%2==0 or num%3==0:
else:
print('prime')
output
a=2
b=3
if num%2==0 or num%3==0:
else:
print('prime')
Q12 Write a program to print following pattern-:
**
***
****
*****
Source code
print('*',end=' ')
print()
output
**
***
****
*****
Source code
for i in range(70,76):
for j in range(76,i-1,-1):
print(chr(j),end=' ')
print()
output
FGHIJ
FGHI
FGH
FG
F
Source code
Source code
tc=0
ta=0
td=0
ts=0
for i in st:
tc+=1
ta+=1
for i in '0123456789':
td+=1
else :
ts+=1
print('total characters',tc)
print('total alphabets',ta)
print('total digits',td)
print('total special',ts)
output
total characters 5
total alphabets 5
total digits 0
total special 0
Source code
for i in range(len(st)):
print(st[i],'-',st.count(st[i])
output
h-1
e-1
y-1
a–1
Source code
the=0
l=st.split()
for i in l:
if len(i)==3 and i[0] in 'Tt' and i[1] in 'hH' and i[2] in 'eE':
the+=1
output
the=0
l=st.split()
for i in l:
the+=1
print('total words',the)
output
total words 0
INDEX