Write a program that allows the user to navigate the lines

Assignment Help Computer Engineering
Reference no: EM132107372

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.

Reference no: EM132107372

Questions Cloud

Estimate the margin of error for samples of size : Back up your statement by using the quick method to estimate the margin of error for samples of size 25 and for samples of size 100.
What is combined reach : You are advertising on two television programs that achieve the reach percentages listed. What is their combined reach?
Ols regression line of x : Line #1 ____ the OLS regression line of x on y, and Line #2 ____ the OLS regression line of x on y.
Determine the probability that a certain number : A professor has 30 students in his or her Chemistry 101 course and wants to determine the probability that a certain number of these 30 students
Write a program that allows the user to navigate the lines : If the line number provided by the user is not numeric, program should handle the conversion exception.
New set of estimated coefficients : Suppose that we regress the number of races a marathon runner wins on the average time it takes the runner in a marathon in minutes and get the estimates
What is the monthly reach of people : The U.S. population of people 13 + is 252,904,000. Expressed as a percentage, what is the monthly reach of people 13 + of Facebook?
What is the projected audience : If the population of Localville is 550,000, what is the projected audience (i.e., the numerical reach)?
What is the probability that both the team a and team b : What is the probability that both the Team A and Team B will win this weekend? What is the probability that only one of the two teams will win this wee

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd