Answer (5-02) for Python for Everybody by Charles R Severance
Exercise 5.2: Write another program that prompts for a list of numbers as
above and at the end prints out both the maximum and minimum of the numbers
instead of the average.
Python for Everybody: Exploring Data Using Python 3
by Charles R. Severance
count = 0
sums = 0
avg = 0
smallest = None
largest = None
while True :
inp_num = input("Enter a number: ")
try :
inp_num = int(inp_num)
count = count + 1
if smallest is None or inp_num < smallest :
smallest = inp_num
if largest is None or inp_num > largest:
largest = inp_num
except :
if inp_num == "done":
print("smallest number: ", smallest)
print("largest number: ", largest)
break
print("invalid input !!!")
continue
sums = sums + inp_num
avg = sums / count
print(sums, count, avg)
quit()