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
>>> 




10 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. where we have to save notepad file ???

    ReplyDelete
  2. alternate code
    count = 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()

    ReplyDelete
  3. Very nice thanks helped me in exams

    ReplyDelete
  4. jai shree ram

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post