Saturday, May 25, 2019

WAP to input the temperature in Fahrenheit and convert it into Celsius and vice versa

print("1: Convert temperature from Fahrenheit to Celsius.")
print("2: Convert temperature from Celsius to Fahrenheit.")
print('-'*10)
choice = int(input('Enter your choice (1, 2): '))
print('-'*10)
if(choice == 1):
        fh = float(input('Enter temperature in Fahrenheit: = '))
        cl = (fh - 32) / 1.8
        print('temperature in Celsius = ' + str(cl))   
elif(choice == 2):
        cl = float(input('Enter temperature in Celsius: = '))
        fh = (cl*1.8)+32
        print('Temperature in Fahrenheit: = ' + str(fh))
else:
        print("Invalid Choice !!!")

No comments:

Post a Comment