Computer Science
Write a program to count the number of upper-case alphabets present in a text file "Article.txt".
Python File Handling
7 Likes
Answer
Let the file "Article.txt" include the following sample text:
PYTHON is a Popular Programming Language.
with open("Article.txt", 'r') as file:
text = file.read()
count = 0
for char in text:
if char.isupper():
count += 1
print(count)
Output
9
Answered By
5 Likes
Related Questions
Write a program to count the words "to" and "the" present in a text file "Poem.txt".
Write a function AMCount() in Python, which should read each character of a text file STORY.TXT, should count and display the occurrence of alphabets A and M (including small cases a and m too).
Example :
If the file content is as follows :
Updated information
As simplified by official websites.The EUCount() function should display the output as :
A or a : 4
M or m : 2Write a program that copies one file to another. Have the program read the file names from user ?
Write a program that appends the contents of one file to another. Have the program take the filenames from the user.