def main(): myTimer = timer.begin_timer() stringer.show_welcome(NAME) should_Exit = False converted_temp = 0.0 while not should_Exit: 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 = round(temp.to_celsius(temperature), 2) print("Degrees Celsisus = ", end=" ") else: converted_temp = round(temp.to_fahrenheit(temperature), 2) print("Degrees Fahrenheit = ", end=" ") print(str(converted_temp)) choice = input("Go again? (y/n): ") if choice.lower() != "y": should_Exit = True # end while loop timer.stop_timer(myTimer) print("Bye!")
def main(): for temp in range(0, 212, 40): print(temp, "Farenheit =", round(temperature.to_celsius(temp), 2), "Celsius") print("*" * 40) for temp in range(0, 100, 20): print(temp, "Celsius =", round(temperature.to_fahrenheit(temp), 2), "Fahrenheit")
def converting(): """Converting """ option = int(input(" Enter The Option \t")) if option == 1: f = float(input(" Enter The Fahrenheit ? ")) c = temp.to_celsius(f) c = round(c, 2) print("Degress Celsius is : ", c) elif option == 2: c = float(input("Enter The Celsius ? ")) f = temp.to_fahrenheit(c) f = round(f, 2) print("Degress Fahrenheit is :", f)
def convert_temp(): option = int(input("Enter a menu option: ")) if option == 1: f = int(input("Enter degrees Fahrenheit: ")) c = temp.to_celsius(f) c = round(c, 2) print("Degrees Celsius:", c) elif option == 2: c = int(input("Enter degrees Celsius: ")) f = temp.to_fahrenheit(c) f = round(f, 2) print("Degrees Fahrenheit:", f) else: print("You must enter a valid menu number.")
def convert_temp(): option = int(input('Enter a menu optino:')) if option == 1: f = int(input('Enter degrees F:')) c = temp.to_celsius(f) c = round(c,2) print('Degree Celsius: %f'%c) elif option == 2: c = int(input('Enter degrees C:')) f = temp.to_degrees(c) f = round(f,2) print('Degree Farenheit: %f'%f) else: print('Enter a valid number')
def convert_temp(): option = int(input("Enter a menu option ")) if option == 1: fahrenheit = int(input("Enter degrees in Fahrenheit ")) celsius = temperature.to_celsius(fahrenheit) celsius = round(celsius, 2) print(f"Degrees Celsius {celsius}") elif option == 2: celsius = int(input("Enter degrees in Celsius ")) fahrenheit = temperature.to_fahrenheit(celsius) fahrenheit = round(fahrenheit, 2) print(f"Degrees Fahrenheit {fahrenheit}") else: print("Tou must enter a valid menu number")
def convert(choice=3): # Fahrenheit to celsius if choice == 1: num = float(input("Enter degrees in Fahrenheit: ")) print("Degrees in Celsius: " + str(round(temperature.to_celsius(num), 1))) # Celsius to fahrenheit elif choice == 2: num = float(input("Enter degrees in Celsius: ")) print("Degrees in Fahrenheit: " + str(round(temperature.to_fahrenheit(num), 1))) # Invalid option elif choice > 2: print("\n\nInvalid choice.")
def test_roundoff(): # 测试函数的名称也必须以“test”开头。 print '''Test that roundoff works''' assert to_celsius( 100) == 38, 'Returning an unrounded result' #not 37.77...
def test_boiling(): # 测试函数的名称也必须以“test”开头。 print '''Test boiling point''' assert to_celsius(212) == 100
def test_roundoff (): '''Test that roundoff works''' assert to_celsius(100) == 38, 'Returning an unrounded result' #not 37.77...
def test_boiling (): '''Test boiling point''' assert to_celsius(212) == 100
def test_roundoff(): '''Test that roundoff works''' assert to_celsius( 100) == 38, 'Returning an unrounded result' #not 37.77...
def test_boiling(): '''Test boiling point''' assert to_celsius(212) == 100
def test_boiling(): assert to_celsius(212) == 100
def test_freezing(): assert to_celsius(32) == 0
def test_roundoff(): assert to_celsius(100) == 38