Conditional statements

while True:
    a = input( ' 1: Celsius to Fahrenheit\n2: Fahrenheit to Celsius\n3: Exit\n ' )
     if a == ' 1 ' :
        celsius = float (input( ' Enter the temperature in Celsius: ' ))
        fahrenheit = (celsius * 9 / 5 ) + 32 
        print( ' {:.2f}Celsius to Fahrenheit is {:.2f}\n ' .format(celsius,fahrenheit))
    elif a == ' 2 ' :
        fahrenheit = float (input( ' Please enter the temperature in Fahrenheit: ' ))
        celsius = 5 / 9 *(Fahrenheit- 32 )
        print( ' {:.2f} The conversion of Fahrenheit to Celsius is: {:.2f}\n ' .format(fahrenheit,celsius))
     else :
         break

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325014500&siteId=291194637