For example, if the given temperature Value is 25C then Celsius value is 25.0C, Fahrenheit value is 77.0F, and Kelvin value is 298.0K
temparature = input("Enter temparature: ")
unit = temparature[-1]
value = temparature[:-1]
if(unit=="C" or unit=="c"):
celcius = float(value);
print(round(celcius,2),"C")
print(round((celcius*9/5)+32,2),"F")
print(round(celcius+273.15,2),"K")
elif(unit=="F" or unit=="f"):
fahr = float(value)
print(round((fahr-32)*5/9,2),"C")
print(round(fahr,2),"F")
print(round((fahr-32)*5/9+273.15,2),"K")
elif(unit=="K" or unit == "k"):
kelv = float(value)
print(round(kelv-273.15,2),"C")
print(round((kelv-273.15)*9/5+32,2),"F")
print(round(kelv,2),"K")
Comments
Leave a comment