Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# average3.py def main(): sum = 0.0 count = 0 x = eval(input(Enter a number (negative to quit) >> )) while x >= 0: sum
# average3.py def main(): sum = 0.0 count = 0 x = eval(input("Enter a number (negative to quit) >> ")) while x >= 0: sum = sum + x count = count + 1 x = eval(input("Enter a number (negative to quit) >> ")) print(" The average of the numbers is", sum / count) main()
_______________________________________________________________________________
# average4.py def main(): sum = 0.0 count = 0 xStr = input("Enter a number (to quit) >> ") while xStr != "": x = eval(xStr) sum = sum + x count = count + 1 xStr = input("Enter a number ( to quit) >> ") print(" The average of the numbers is", sum / count) main()
Test files average3.py, average4.py
With a single .txt file, revise 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started