Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python: Write a program that asks the user for a file name. Assume the file contains a series of integers, each written on a separate

Python: Write a program that asks the user for a file name. Assume the file contains a series of integers, each written on a separate line. The program should read the contents of the file into a list and then display the following data:

The lowest number in the list The highest number in the list The sum of the numbers in the list The average of the numbers in the list

Include in your program the following functions:

find_lowest() - accepts a list as it's only argument. Returns the lowest value in the list.

find_highest() - accepts a list as it's only argument. Returns the hight value in the list.

find_average() - accepts a list as it's only argument. Returns the average of all values in the list.

find_total() - accepts a list as it's only argument. Returns the sum of all values in the list.

display() - accepts the high value, low value, average value, and total values returned by the functions as it's only arguments. Displays the values with appropriate labels. Format the average to two decimal places of precision.

main() - the function containing the mainline logic. It supports the calling of functions and passing of data between the functions.

None of the "find" functions interact with the user in any way (no input or print statements). main() only asks for the filename and, optionally, reports if the file failed to open. Use main to read the values from the file into a list and pass the list to each "find" function in turn. Store the values returned from each "find" function into a separate variable. Then, pass those variables to the display function.

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_2

Step: 3

blur-text-image_3

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions