Question: Python Code in Python please. Here's the contents of the file: Write a function to read out numbers stored in a text file. The file

Python

Python Code in Python please. Here's the contents of the file: Writea function to read out numbers stored in a text file. The

Code in Python please.

Here's the contents of the file:

file contains only one line that stores multiple numbers. Each number is

Write a function to read out numbers stored in a text file. The file contains only one line that stores multiple numbers. Each number is separated by one or more commas. The first and the second numbers are separated by one comma. The second and the third numbers are separated by two commas. The third and the fourth numbers are separated by three commas. And so on. No space is allowed before or after any comma. There is no comma after the last number; in other words, the line will not end with a comma. For the following example, eight numbers are stored in that line. 51,2,,2,,,49,14,15,11,12,11,1,1,1,1,1,14 The function should be named decipher and be able to accept a string, representing a file name, as argument. It should be able to read all numbers stored in the designated file, and return their average. A sample file, named H9_Decipher_Sample.txt, is provided for your unit testing. If your implementation is correct, decipher ("H9_Decipher_Sample.txt") should return 17.0, because the average of the numbers stored in the provided sample file H9_Decipher_Sample.txt is 17.0. Please do unit testing with different text file formats on both Apple and Windows platforms to make sure your program can correctly handle their incompatibilities, if any. Please do unit testing with different text file formats on both Apple and Windows platforms to make sure your program can correctly handle their incompatibilities, if any. Your decipher function should be able to take any file name as an argument and read all numbers stored in that designated file. After function design, continue to write code to interact with users for reading and processing numbers read from a file by using your defined decipher function. Your code shall prompt for a file name and then display a message to report the average of all numbers stored in the designated file. Function specifications: Function name o decipher Input parameter o a string that is a file name return value o a number that is the average of all numbers stored in the designated file User interface specifications: 51,2,,2,,,49,14,15,11,,2,,,,,,,,,,,,,14

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!