#################################################################### # # Method(s) to read specific types from the keyboard. # # Reading a float number from the keyboard. # def read_float(question, minimum=None, maximum=None): """Read a float value from the command line""" # Validate input as early as possible. value = raw_input(question) value = float(value) # check if the input is within limits if minimum is not None and value < minimum: print 'ERROR: value = ',value,' smaller than minimum',minimum,'.' exit(1) if maximum is not None and value > maximum: print 'ERROR: value = ',value,' larger than maximum',maximum,'.' exit(1) return value