Temperature Conversion – Python Lab Program

This program gets the choice of the user

  • whether to convert from Fahrenheit to Celsius
  • or Celsius to Fahrenheit

then uses IF and ELIF (header) to run the corresponding conversion code within the blocks (suite)

this program also includes an ELSE section to run when an invalid choice is given.

Note: ch=ch.upper() converts the value inside “ch” to UPPER case character.

ch=input("Enter the choice F(for Farenheit to Celcius)\n or C(for Celcius to
Farenheit): ")
f=float(input("Enter the Farenheit Value: "))
print("Farenheit to Celcius")
print("The Celcius value for the given Farenheit",f," is ",c, "C")
elif (ch=='C'):
c=float(input("Enter the Celcius Value: "))
print("Celcius to Farenheit")
print("The Farenheit value for the given Celcius",c,"is",f,"F")
else :
print("Invalid Choice")

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.