Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# average5.py def main(): fileName = input(What file are the numbers in? ) infile = open(fileName,'r') sum = 0.0 count = 0 for line in

# average5.py def main(): fileName = input("What file are the numbers in? ") infile = open(fileName,'r') sum = 0.0 count = 0 for line in infile: sum = sum + eval(line) count = count + 1 print(" The average of the numbers is", sum / count) main()

__________________________________________________

# average6.py def main(): fileName = input("What file are the numbers in? ") infile = open(fileName,'r') sum = 0.0 count = 0 line = infile.readline() while line != "": sum = sum + eval(line) count = count + 1 line = infile.readline() print(" The average of the numbers is", sum / count) main()

Test all files, average5.py, average6.py a

3. With a single .txt file, revise all files with line-by-line explanation. (Using # to add comment/explanation).

One file with line-by-line explanation, followed by one running result with IDLE shell information (try to use the same testing inputs to see the differences between each .py files).

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

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions