Temperature Conversion in Python

Today, we will see how to do temperature conversion in Python. We will convert from one unit of temperature to other units of temperature in Python. We will ask the user to enter the temperature. We will consider the input temperature’s to be celsius and we will convert them to the other two units of temperature i.e. Fahrenheit and Kelvin.

The formula for converting Celsius to Fahrenheit is celsius * (9/5) + 32

The formula for converting Celsius to Kelvin is celsius + 273.15.

Code for Temperature Conversion in Python

try:
    celsius = int(input("Enter temperature value in celsius(integer only): "))
    
    # converting celsius to Fahrenheit
    Fahrenheit = celsius * (9/5) + 32
    
    # converting celsius to Kelvin
    Kelvin = celsius + 273.15
    
    print("Temperature in Fahrenheit is: ", Fahrenheit)
    print("Temperature in Kelvin is: ", Kelvin)
    
except:
    print("Invalid input")

Output:

Temperature Conversion in Python | Assignment Expert

Also Read:

Share:

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@copyassignment.com Thank you