0% found this document useful (0 votes)
38 views4 pages

Programs in Python

The document contains 3 programming problems. The first program checks if two strings are anagrams by comparing the sorted letters. The second program takes input for multiple strings, sorts them alphabetically, and prints the result. The third program counts and prints the number of vowels and consonants in a given word or sentence, and also prints the input in uppercase and lowercase.

Uploaded by

blogger
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views4 pages

Programs in Python

The document contains 3 programming problems. The first program checks if two strings are anagrams by comparing the sorted letters. The second program takes input for multiple strings, sorts them alphabetically, and prints the result. The third program counts and prints the number of vowels and consonants in a given word or sentence, and also prints the input in uppercase and lowercase.

Uploaded by

blogger
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

PROBLEM 1:

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:

You might also like