Programs in Python
Programs in Python
ANAGRAM
Program:
s1=input('Enter the first string: ')
s2=input('Enter the second string: ')
if (sorted(s1)==sorted(s2)):
print('They are anagrams')
else:
print('They are not anagrams')
Output:
PROBLEM 2:
Arranging strings
Program:
n=int(input('Enter the number of strings: '))
l=[]
for i in range(0,n):
s=input('Enter the string: ')
l.append(s)
l=sorted(l)
print(l)
Output:
PROBLEM 3:
Program:
s=input('Enter the word or sentence: ')
vowels='aeiouAEIOU'
cons='bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'
if (len(s)>100):
print('Invalid input')
else:
count1=0
count2=0
for ch in s:
count=vowels.count(ch)
count1=count1+count
print('Number of vowels= ',count1)
for ch in s:
count=cons.count(ch)
count2=count2+count
print('Number of consonants= ',count2)
print(s.upper())
print(s.lower())
Output: