Write a program that reads in numbers from the user. Your program should be capa
ID: 3839018 • Letter: W
Question
Write a program that reads in numbers from the user. Your program should be capable of tracking/calculating the minimum, maximum, total sum, and average of the numbers entered. When the user enters "q", "Q", or "quit", the program should display the minimum, maximum, total sum, and average of the numbers entered before ending. You can assume that the user will always enter either a number or one of the strings "q", "Q", or "quit". You can also assume the user will always enter at least one number (i.e., they will not immediately choose to quit upon starting the program). Save your Python program in a file called a2q3.py and add it to your submission zip file.Explanation / Answer
def program() :
sum = 0
min = 1000
max = 0
count = 0
while True:
x = input ('Enter:')
if x == 'q' or x == 'Q' or x == 'quit':
break
else:
sum = sum + int(x)
if int(x) > max:
max = int(x);
if int(x) < min:
min = int(x)
count = count + 1
print ('Max:',max,'Min:', min, 'Sum:',sum, 'Avg:', sum/count )
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.