Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

Code in Python please.

Here's the contents of the file:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago