Question: # 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
Get step-by-step solutions from verified subject matter experts
