P01 - Fahrenheit To Celsius and Vice Versa
P01 - Fahrenheit To Celsius and Vice Versa
Python Program to convert the given temperature from Fahrenheit to Celsius and vice versa depending
Aim : To convert the given temperature from Fahrenheit to Celsius and vice versa depending upon user’s
choice.
Procedure:
Step 6: if the choice is 1 then get Celsius, convert it into Fahrenheit and Display the Result
Step 7: if the choice is 2 then get Fahrenheit, convert it into Celsius and Display the Result
Step 8: if the choice is 3 then break the infinite loop and Display Success and Stop the Program
Step 10: the control will transfer to the next iteration to the infinite loop
Result: Program to convert the given temperature from Fahrenheit to Celsius and vice versa depending upon
user’s choice is done successfully.
Program:
while(True):
print("\n1.Celsius to Fahrenheit ")
print("2.Fahrenheit to Celsius ")
print("3.Exit")
ch=int(input("Enter your choice:"))
if ch==1:
# Input
celsius = float(input("Enter temperature in Celsius: "))
elif ch==3:
break;
else:
print("\nInvalid Choice. Choice should be 1 or 2 or 3.")
print("Success.")
Output:
>>>
1.Celsius to Fahrenheit
2.Fahrenheit to Celsius
3.Exit
Enter your choice:1
Enter temperature in Celsius: 20
1.Celsius to Fahrenheit
2.Fahrenheit to Celsius
3.Exit
Enter your choice:2
Enter temperature in Fahrenheit: 68
1.Celsius to Fahrenheit
2.Fahrenheit to Celsius
3.Exit
Enter your choice:4
1.Celsius to Fahrenheit
2.Fahrenheit to Celsius
3.Exit
Enter your choice:3
Success.
>>>