# Compute the average of a collection of positive values entered by the user. # The user will enter 0 or a negative number to indicate that no further # values will be entered. The 0 or negative number is *NOT* included in the # average. # Initialize total and count total = 0 count = 0 # Read the first value from the user val = float(input("Enter a number (0 or negative to quit): ")) # While the input is positive while val > 0: # Add the input value to the total total = total + val # Increment count count = count + 1 # Read the next input value val = float(input("Enter a number (0 or negative to quit): ")) if count > 0: # Compute the average average = total / count # Display the result print("The average of those values is", average) else: print("An average cannot be displayed because no values were entered.")