Пример #1
0
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!")
Пример #2
0
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")
Пример #3
0
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)
Пример #4
0
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 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")
Пример #6
0
def convert_temp():
    option = eval(input('Enter a Menu Option:'))
    if option == 1:
        f = eval(input('Enter Degree Fahrenheit:'))
        c = temp.to_celcius(f)
        c = round(c, 2)
        print('Degree Celsius:', c)
    elif option == 2:
        c = eval(input('Enter Degree Celsius:'))
        f = temp.to_fahrenheit(c)
        f = round(f, 2)
        print('Degree Fahrenheit:', f)
    else:
        print('You must Enter a valid Menu number')
Пример #7
0
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.")