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

  What events might occur to interrupt the utility

Name a utility required by a data center. What events might occur to interrupt this utility? Atleast 400 Words With No Plagarism.

  What is complementing and why is it important

What is complementing and why is it important? How many bytes are in a kilobyte, megabyte, gigabyte, terabyte, and petabyte?

  Describe an application life cycle management product

Using Google or another search engine, Describe an Application Life Cycle Management product which could meet the needs of Sifers-Grayson.

  How your employment is directly related to your field

Explain how your employment is directly related to your field of study? Business Disaster and Recovery Planning and Information Security and Risk Management.

  What items of input must the user enter

What items of input must the user enter? Once the input has been entered, how will the program determine the average? What output will the program display?

  What are the most common numbers for ip acls

What is an access control list? What's the most common type of ACL? What are the most common numbers for IP ACLs? How can you filter traffic using ACLs? What's the order of operations in an ACL?

  Write a recursive program to compute the largest integer

Write a recursive program to compute the largest integer less than log2 N. Write an iterative program for the in the previous exercise.

  Create a new table containing the four columns

Create a new table containing these four columns from the existing BOOKS table: ISBN, Cost, Retail, and Category.

  Questionsstudy any two multicore processor architecture and

questionsstudy any two multicore processor architecture and discuss the following features briefly.a bus architectureb

  List what might be done to provide fault tolerance

Equipment and system failure: Search for information on system and equipment failure on your favorite search engine.

  Pros and cons to approach the project as adaptive sdlc

ITC548 - System Analysis Assignment 3 - Requirements Report. Write brief description of the Pros and Cons to approaching the project using the 'Predictive' SDLC

  How many such matrices are there in each

In this problem, we are concerned with two dimensional arrays (matrices) that have 20 rows and 20 columns; further, each entry is a member of {1, 2, 3}.

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