Q. Write a program to count the number of upper- case alphabets present in a text file "Article.txt".
You can understand by Watching video :-
Answer :-
count = 0 file = open("Article.txt","r") sen = file.read() for i in range ( len(sen) ) : if sen[ i ].isupper() : count += 1 print("Number of upper case alphabet : ", count) file.close()
Article.txt Contains :-
A boy is playing there. There is a playground. An aeroplane is in the sky. Alphabets & numbers are allowed in password. This is Path Walla Website..
Output :-
Number of upper case alphabet : 8
>>>
Thanku So much
ReplyDeleteWelcome : )
Deletewhere we have to save notepad file ???
ReplyDeletewhere your program file has save.
Deletealternate code
ReplyDeletecount = 0
file = open("pathwala.txt","r")
sen = file.read()
for i in sen :
if i.isupper() :
count += 1
print("Number of upper case alphabet : ", count)
file.close()
Correct.
DeleteVery nice thanks helped me in exams
ReplyDeleteWelcome : )
Deletetahnks baby
Deletejai shree ram
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )