Write a Python program to convert temperatures to and from celsius, fahrenheit.
[ Formula : c/5 = f-32/9 [ where c = temperature in celsius and f = temperature in fahrenheit ]
Expected Output :
60°C is 140 in Fahrenheit
45°F is 7 in Celsius
t = input('Temperature = ')
t, v = t.split('°')
t = int(t)
if v.lower() == 'c':
f = t*(9/5) + 32
print(f"{t}°C is {f:.0f} in Fahrenheit")
elif v.lower == 'f':
c = (t - 32)*5/9
print(f"{t}°F is {c} in Celsius")
Comments
Leave a comment