subject

PYTHON CODE ONLY The Program Spec
Write a program that enforces the following expectations of a data set file:
The file must exist
The data in the file must have the following format:
The file must start with an integer, n
The file must contain n data values
The program prompts the user for the name of a file. The file is expected to contain data values. The first line of the file should contain the total number of values, and the remaining lines contain the data.
Three key potential errors to program for include:
The file might not begin with an integer
There might not be a sufficient number of data values
There may be additional input after reading all data values
For a valid data file, the processing data task is to compute the sum of all the data values in the file. Print out a result message and resultant sum for a valid data file.
Deliverable: yournameLab6.py Your source code solution and a copy of the run pasted into your source submission file. Be sure to comment out your run so that your .py file will still run in the grader test bed.
Input Error Checking: 5 test files are provided to use as test cases for your program. 4 test cases are expected to raise exception conditions. 1 test case is a valid data set. The test files include: bad1.dat bad2.dat bad3.dat bad4.dat good. dat
Test Run Requirements: Use the provided 5 test files as your test run validator.
Here are some other tips and requirements:
1. Keep provided test files intact
2. Use a while loop to run all 5 test files as your input test suite to generate submission run output
3. Provide an appropriate display message both for invalid and valid data files.
Here is a sample partial run:
$ python3 demo6.py
Please enter the file name: err1.dat
Error: file contents invalid.

Please enter the file name: err2.dat
Error: End of file expected.
Please enter the file name: valid. dat
The sum is 145
bad1.dat
10 1 2 3 4 5 6 7 8 9
bad2.dat
ten 1 2 3 4 5 6 7 8 9
bad3.dat
10 one 2 3 4 5 6 7 8 9
bad4.dat
10 1 2 3 4 5 6 7 8 9 10 11
good. dat
10 1 2 3 4 5 6 7 8 9 10

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 18:30
Write a program that prints the day number of the year, given the date in the form month-day-year. for example, if the input is 1-1-2006, the day number is 1; if the input is 12-25-2006, the day number is 359. the program should check for a leap year. a year is a leap year if it is divisible by 4, but not divisible by 100. for example, 1992 and 2008 are divisible by 4, but not by 100. a year that is divisible by 100 is a leap year if it is also divisible by 400. for example, 1600 and 2000 are divisible by 400. however, 1800 is not a leap year because 1800 is not divisible by 400.
Answers: 3
question
Computers and Technology, 24.06.2019 03:30
Which explains extrinsic motivation? a)motivation in which there is a reward b)motivation that is personally satisfying c)motivation that is personally meaningful d)motivation in which the subject is interesting
Answers: 1
question
Computers and Technology, 24.06.2019 03:30
It is not necessary to develop strategies to separate good information and bad information on the internet. true or false
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
1. web and mobile applications allow users to be actively engaged in an online activity. a true b false 2. some examples of business applications purposes are to collaborate, share files, meet virtually in real-time, and accept payments. a true b false 3. an education application would most likely do which of the following? a allow users to watch popular movies and tv shows b connect users with social and business contacts c confirm users' travel plans d teach users a new language 4. a uniform resource locator (url) is how the internet knows where to take users when an address is typed into a browser. a true b false 5. deon is required to provide the citation information for his sources. what type of information should he collect from his sources? a author name, title, date of publication, date of access, url b connections to background information c interesting facts and statistics d notes on important information
Answers: 1
You know the right answer?
PYTHON CODE ONLY The Program Spec
Write a program that enforces the following expectations of...
Questions
question
Mathematics, 11.10.2021 09:50
question
Mathematics, 11.10.2021 14:00
question
Computers and Technology, 11.10.2021 14:00
Questions on the website: 13722363