Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

This program should be written in PYTHON: add error checking (Raising and Handling Exception):

1. Program should handle file not found exception, if the input file does not exist

2. Program should raise an exception if the file is empty

3. If the line number provided by the user is not numeric, program should handle the conversion exception

4. If the line number provided is greater than the number of lines in the file, the program should raise a ValueError exception.

Note: This may cause the program to exit 5. Write a program that allows the user to navigate the lines of text in a file.

The program should prompt the user for a filename. The program should use a function, loadData, to accomplish the following:

Load the file content into a dictionary, fileContent, which will contain each line and its corresponding line number.

The function should also populate a second dictionary, fileInfo, with each word in the file and the number of times each word appears in the file. Once the loadData function completes, the program will print the contents of fileInfo dictionary; each word and its count appearing on a separate line.

The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the program quits. Otherwise, the program prints the line (text) associated with that line number.

Note: The loadData function take one argument, the name of the file. your function name must be loadData which should include all code that uses dictionary fileContent fileInfo to save number of line and word frequency

Your code is should include dictionary fileContent that stores number of line that counted. You code is should include dictionary fileInfo that stores words' frequency and prints it .

Your loop supposed to be working with fileContent which has number of line as key.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93094841

Have any Question?


Related Questions in Computer Engineering

Systems analysis project 8 can you answer the 4 questions

Systems analysis project 8: can you answer the 4 questions at the task section please, thank you. Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the ...

Question recall the on the spot courier service introduced

Question : Recall the On the Spot courier service introduced in Unit 1. The details of the package pickup and delivery process are described here. When Bill got an order, at first, only on his phone, he recorded when he ...

Systems analysis projectpersonal trainer inc owns and

Systems analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

Subject digital securityprovide an fidm authentication

subject : Digital Security Provide an FIdM authentication system that you have used (being subjet to). Tell the name of the organizations acted as the IdP (Identity Provider) and SP (Service Provider)?

Describe a ping of death attack as an attack that causes

Describe a ping of death attack as an attack that causes the victim computer to freeze and malfunction.

All rsa cryptosystem has public key n 35 and e 7 messages

All RSA cryptosystem has public key N = 35 and e = 7. Messages are encrypted one letter at a time, converting letters to numbers by A = 2, B = 3, .... Z = 27, space = 28. Showing your working, encrypt the message: BE GOO ...

A bit-comparator is a combinational circuit with 2 inputs a

A Bit-Comparator is a combinational circuit with 2 inputs, A and B, and 3 outputs. L, E and G. Output L is 1 if A Output E is 1 if A = B, otherwise E is 0. Output G is 1 if A > B, otherwise G is 0. Show how the 2x4 decod ...

Benefits of abating emission mb500-20acost of abating

Benefits of abating emission: MB=500-20A Cost of abating emission: MC=200+5A What are the marginal benefit and marginal cost of abatement at socially efficient level of abatement? What is the net social benefit at the ef ...

From slide number 1-37 how did we get value 00004 show all

From slide number 1-37, how did we get value 0.0004? Show all your work. Describe the most popular wireless Internet access technologies today. Compare and contrast them. What is the key distinguishing difference between ...

Assessment - managing services and securitytask - in this

Assessment - Managing Services and Security Task - In This Assignment your job is to create two Virtual machines each running a different but the latest distribution of Linux e.g. Ubuntu Server and CentOS. Each of these ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As