Question
python question!
points) Attached to the Exam #4 code Assignment in Tracs you ## will find a file, text.txt. Text is stored 1 sentence per l
0 0
Add a comment Improve this question Transcribed image text
Answer #1

https://onlinegdb.com/B1gvhAZZw

f = open("text.txt", "r")
s=f.read();
L=[0,0,0,0];
for i in range(len(s)):
if(s[i]>='a' and s[i]<='z'):
L[0]+=1;
if(s[i]>='A' and s[i]<='Z'):
L[1]+=1;
if(s[i]>='0' and s[i]<='9'):
L[2]+=1;
if(s[i]==' '):
L[3]+=1;
print("Number of uppercase characters in the file are: "+str(L[1]));
print("Number of lowercase characters in the file are: "+str(L[0]));
print("Number of digits in the file are: "+str(L[2]));
print("Number of whitespace characters in the file are: "+str(L[3]));

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
python question! points) Attached to the Exam #4 code Assignment in Tracs you ## will find...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • i need the answer for this python question using dictionary method please!!! points) Attached to the...

    i need the answer for this python question using dictionary method please!!! points) Attached to the Exam #4 code Assignment in Tracs you ## will find a file, "text.txt". Text is stored 1 sentence per line. ## Write a program below that reads the file contents and displays ## the following: 1. Number of uppercase characters in the file 2. Number of lowercase characters in the file 3. Number of digits in the file. 4. Number of whitespace characters in...

  • Python Programming 4th Edition: Need help writing this program below. I get an error message that...

    Python Programming 4th Edition: Need help writing this program below. I get an error message that says that name is not defined when running the program below. My solution: def main(): filename = "text.txt" contents=f.read() upper_count=0 lower_count=0 digit_count=0 space_count=0 for i in contents: if i.isupper(): upper_count+=1 elif i.islower(): lower_count+=1 elif i.isdigit(): digit_count+=1 elif i.isspace(): space_count+=1 print("Upper case count in the file is",upper_count) print("Lower case count in the file is",lower_count) print("Digit count in the file is",digit_count) print("Space_count in the file is",space_count)...

  • You're to write a C++ program that analyzes the contents of an external file called data.txt....

    You're to write a C++ program that analyzes the contents of an external file called data.txt. (You can create this file yourself using nano, that produces a simple ASCII text file.) The program you write will open data.txt, look at its contents and determine the number of uppercase, lowercase, digit, punctuation and whitespace characters contained in the file so that the caller can report the results to stdout. Additionally, the function will return the total number of characters read to...

  • Python: The attached text file: https://drive.google.com/open?id=1Hcj4Ey4NbKHn5-vyF-foR3iny0aX8y1...

    Python: The attached text file: https://drive.google.com/open?id=1Hcj4Ey4NbKHn5-vyF-foR3iny0aX8y1c Unique Words Write a program that opens a specified text file and then displays the number of unique words in the text file after stripping all the white spaces, comma, and the punctuation marks and a list of all the unique words found in the file. The list should be sorted in alphabetical order. The program should handle the ‘file not found’ error. Store each word as an element of list. Be sure not...

  • Could anyone please help with this Python code assignment? In this programming assignment you are to...

    Could anyone please help with this Python code assignment? In this programming assignment you are to create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The count of how many numbers are in the file. The average of the numbers. The average is the sum of the numbers divided by how many there are. The maximum value. The...

  • I am new to Python and am having trouble coming up with writing code to the...

    I am new to Python and am having trouble coming up with writing code to the following problem... The program must: Prompt for a file name Opens that file and reads through the file Displays a custom error message if the file does not exist You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon. From [email protected] Sat Jan 5 09:14:16 2008 Accumulated the...

  • Write a Python program to read lines of text from a file. For each word (i.e,...

    Write a Python program to read lines of text from a file. For each word (i.e, a group of characters separated by one or more whitespace characters), keep track of how many times that word appears in the file. In the end, print out the top twenty counts and the corresponding words for each count. Print each value and the corresponding words, in alphabetical order, on one line. Print this in reverse sorted order by word count. You can assume...

  • In python Attached is a file called sequences.txt, it contains 3 sequences (one sequence per line)....

    In python Attached is a file called sequences.txt, it contains 3 sequences (one sequence per line). Also attached is a file called AccessionNumbers.txt. Write a program that reads in those files and produces 3 separate FATSA files. Each accession number in the AccessionNumbers.txt file corresponds to a sequence in the sequences.txt file. Remember a FASTA formatted sequence looks like this: >ABCD1234 ATGCTTTACGTCTACTGTCGTATGCTTTACGTCTACTGACTGTCGTATGCTTACGTCTACTGTCG The file name should match the accession numbers, so for 1st one it should be called ABCD1234.txt. Note:...

  • Python 3.7 Coding assignment This Program should first tell users that this is a word analysis...

    Python 3.7 Coding assignment This Program should first tell users that this is a word analysis software. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file. A word may appear in multiple lines. A word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT