# # This program finds the average of the inputed numbers. # Uses sentinel approach. # A sentinel here is an empty string # def main(): print("This program finds the average of inputed numbers") sum_ = 0 # the sum of provided values counter = 0 # counter for the number of provided values ns='0' # values entered by the user are referenced to by next_value try: while ns != "": # termination condition: no value provided sum_ = sum_ + float(ns) # adding the provided value to the sum counter = counter+1 # incrementing the number of added values ns = input("Please, input a number (press to stop):") except: print("Incorrect input.") if counter > 1: average = float(sum_)/(counter-1) # average print("The average of the entered numbers, rounded off to the nearest hundrendth,\ is {0:0.2f}".format(average)) main()