def main(): myTimer = timer.begin_timer() stringer.show_welcome(NAME) converted_temp = 0.0 while True: converter = Temp() # create instance of Temp class obj print() # get input from the user scale = input("Enter current scale \'F\' or \'C\':\t") if scale.lower() != 'c' and scale.lower() != 'f': print("ERROR, invalid scale. Please try again.") continue try: temperature = float(input("Enter current temperature:\t")) except ValueError: print("ERROR, temperature should be a number. Please try again.") continue if scale.lower() == 'f': converted_temp = converter.getCelsius(temperature) print("Degrees Celsisus = ", end=" ") else: converted_temp = converter.getFahrenheit(temperature) print("Degrees Fahrenheit = ", end=" ") print(str(converted_temp)) choice = input("Go again? (y/n): ") if choice.lower() != "y": break # end while loop timer.stop_timer(myTimer) print("Bye!")
def convert_temp(): option = int(input("Enter a menu option: ")) temp = Temp() if option == 1: f = int(input("Enter degrees Fahrenheit: ")) temp.setFahrenheit(f) print("Degrees Celsius:", temp.getCelsius()) elif option == 2: c = int(input("Enter degrees Celsius: ")) temp.setCelsius(c) print("Degrees Fahrenheit:", temp.getFahrenheit()) else: print("You must enter a valid menu number.")
def convert_temp(): temp = Temp() option = int(input("Enter a menu option: ")) if option == 1: f = int(input("Enter degrees Fahrenheit: ")) c = temp.setFahrenheit(f) c = temp.getCelsius(f) # c = temp.to_celsius(f) # c = round(c, 2) print("Degrees Celsius:", c) elif option == 2: c = int(input("Enter degrees Celsius: ")) f = temp.setCelsius(c) f = temp.getFahrenheit(c) # f = temp.to_fahrenheit(c) # f = round(f, 2) print("Degrees Fahrenheit:", f) else: print("You must enter a valid menu number.")