Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.
Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.
temperature = input()
scale=temperature[-1]
temperature=temperature[0:len(temperature)-1]
temperature=float(temperature)
if scale.upper()=='C':
F=(9/5)*temperature + 32
K=temperature+273.15
print(f"{round(temperature,2)}C")
print(f"{round(K,2)}K")
print(f"{round(F,2)}F")
elif scale.upper()=='F':
C=(temperature-32)*(5/9)
K=C+273
print(f"{round(temperature,2)}F")
print(f"{round(C,2)}C")
print(f"{round(K,2)}K")
elif scale.upper()=='K':
C=temperature-273
F=(9/5)*int(C) + 32
print(f"{round(temperature,2)}K")
print(f"{round(C,2)}C")
print(f"{round(F,2)}F")
else:
print("Wrong temperature format")
Comments
Leave a comment