#******************************************************************** # # Ima P. Programmer # Introduction to Computer Programming # Programming Project #0: Project Title # January 1, 1970 # Instructor: Michael Scherger # #********************************************************************Each procedure or function should have a documentation "header" that includes the following information
#******************************************************************** # # Ask User To Enter A Number Function # # This function prints a question string and prompts the to the user to # enter a number between low and high-1. The function returns a valid # number within the range. # # Return Value # ------------ # response integer valid number in range [low, high) # # Arguments # --------- # question string question string to be printed # low integer low value in range # high integer high value in range # # Local Variables # --------------- # response integer valid number in range (also used as a return value) # #******************************************************************* def ask_number(question, low, high): """Ask for a number within a range.""" # local variables response = None # loop...prompt user and test if response is in the range while response not in range(low, high): response = int(raw_input(question)) # return to calling function return response