You are on page 1of 11

# Program1:WAPto accepta string andwhether itisa palindrome ornot.

str=input("enter the

string")l=len(str)

p=l-

1index=

while(index<p):if(str[index

]==str[p]):

index=index+1

p=p-1

else:

print("stringisnotapalindrome")br

eak

else:

print("stringispalindrome")

#Program2 : WAP to counts the number of alphabets ,digits, uppercase, lowercase, #


spacesandother characters(status ofa string).

str1 =input("enter a

string")n=c=d=s=u=l=o=0

forchinstr1:

ifch.isalnum():
n+=1

ifch.isupper():

u=u+1

elifch.islower():l

=l+1

elifch.isalpha():

c=c+1

elifch.isdigit():

d=d+1

elifch.isspace():

s=s+1

else:

o=o+1

print("no.of alpha and

digit",n)print("no.of capital

alpha",u)print("no.ofsmallalph

abet",l)print("no.ofdigit",d)
print("no.ofspaces",s)print("no

ofothercharacter",o)

Program 3:WAPtoremove all oddnumbersfromthegivenlist.

L=[2,7,12,5,10,15,23]

foriin L:

if i

%2==0:L.r

emove(i)

print(L)

#Program 4:WAPto displayfrequenciesof alltheelement of alist.

L=[3,21,5,6,3,8,21,6]

L1=[]

L2=[]

foriin L:

if i not in

L2:x=L.coun

t(i)L1.append

(x)L2.append

(i)
print('element','\t\t\

t',"frequency")foriin

range(len(L1)):

print(L2[i],'\t\t\t',L1[i])

#Program 5:WAPto displaythosestringwhich startswith‘A’ fromthegivenlist.

L=['AUSHIM','LEENA','AKHTAR','HIBA','NISHANT','AMAR']

count=0f

oriinL:

if i[0] in

('aA'):count=c

ount+1print(i)

print("appearing",count,"times")
#

You might also like