Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey I need help with this question don't understand how to do it must use try and except in code for python cheers . Write

Hey I need help with this question don't understand how to do it must use try and except in code for python cheers

image text in transcribed

. Write a Python program to complete the following steps: prompt the user to enter a filename, read through a list of words from the file, convert all words into lower case, close the input file, count the frequency of each word using a dictionary, print the word-frequency dictionary in sorted keys (alphabetically) order as shown in the examples below, and Use try-except block to handle any exceptions that may occur. Note: If the file cannot be opened, the function should print "ERROR: The file 'xxx' does not exist." where xxx indicates the filename. Note: remember to close the file properly if the file can be opened. You *must* use the try... except syntax and handle the FileNotFoundError in your solution. For example: Input Result temp.txt Enter a filename: temp.txt $200:1 a:2 collect:1 do: 2 go:1 is: 2 not:2 only:1 pass:1 test:2 this: 2 error.txt Enter a filename: error.txt ERROR: The file 'error.txt' does not exist. Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) 1 -try: 2 except FileNotFound: 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

Describe the evolution of desktop and mobile operating systems

Answered: 1 week ago

Question

3. Design a program for preparing for cross-cultural assignments.

Answered: 1 week ago

Question

2. Develop a program for effectively managing diversity.

Answered: 1 week ago

Question

7. What is coaching? Is there only one type of coaching? Explain.

Answered: 1 week ago