You are on page 1of 2

FILE HANDLING - PROGRAM 1

QUESTION:
Write a program to read a text file and display the number of vowels,
consonants, uppercase, lowercase, digits characters in the file ‘ipl.txt’.
1. Mumbai Indians
2. Chennai Super Kings
CODE:
a=open('ipl.txt')
data=a.read()
v_cnt=0
v_cnt=c_cnt=u_cnt=l_cnt=n_cnt=0
for i in data:
if i in 'AEIOUaeiou':
v_cnt+=1
if i not in 'AEIOUaeiou' and i.isalpha():
c_cnt+=1
if i. isupper():
u_cnt+=1
if i.islower():
l_cnt+=1
if i.isdigit():
n_cnt+=1
print('Number of vowels:',v_cnt)
print('Number of consonants:',c_cnt)
print('Number of uppercase:',u_cnt)
print('Number of lowercase:',l_cnt)
print('Number of digits:',n_cnt)
OUTPUT:
Number of vowels: 12
Number of consonants: 18
Number of uppercase: 5
Number of lowercase: 25
Number of digits: 2

You might also like