0% found this document useful (0 votes)
5 views

Code (4)

Uploaded by

shivamsgaming49
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Code (4)

Uploaded by

shivamsgaming49
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#----------- Temperature Converter -------------#

choice = input("Would you like to convert the temperature to kelvin, degree


celsius or fahrenheit : ").lower()

if choice == "celsius":
tempci = int(input("Please enter the temperature (in degree celsius) : "))
tempc = float(tempci)
tempk = tempc + 273.16
tempf = (tempc * (9/5)) + 32
print(f"The given temperature is {tempk} Kelvin or {tempf} Fahrenheit ")

elif choice == "kelvin":


tempki = eval(input("Please enter the temperature (in kelvin) : "))
tempk = float(tempki)
tempc = tempk - 273.16
tempf = (tempc * (9/5)) + 32
print(f"The given temperature is {tempc} Degree Celsius or {tempf}
Fahrenheit ")

elif choice == "fahrenheit":


tempfo = int(input("Please enter the temperature (in fahrenheit) : "))
tempf = float(tempfo)
tempc = (tempf - 32)*(5/9)
tempk = tempc - 273.16
print(f"The given temperature is {tempc} Degree Celsius or {tempk} Kelvin ")

You might also like