# average3.py # From Zelle textbook p240 # # Average numbers using a sentinal loop (a while loop with a sentinal) # The sentinal must be some item not in the input set # Negative numbers can't be averaged in this program def main(): sum = 0.0 count = 0 x = input("Enter a number (-1 to quit): ") # priming the loop while x >= 0: sum = sum + x count = count + 1 x = input("Enter a number (-1 to quit): ") print"\nAverage is: ", sum/count main()