0% found this document useful (0 votes)
21 views2 pages

11 - File Handling Program 1

The document details a program that reads a text file and counts the number of vowels, consonants, uppercase letters, lowercase letters, and digits. The program outputs these counts for the given text file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

11 - File Handling Program 1

The document details a program that reads a text file and counts the number of vowels, consonants, uppercase letters, lowercase letters, and digits. The program outputs these counts for the given text file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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