Temperature conversion in
Program
t = input('Enter temperature: ').split()
if len(t) != 2:
print('incorect input')
else:
t, d = int(t[0]), t[1].lower()
if d in ('c', 'k', 'f'):
if d == 'c':
k = t + 273.15
f = t*1.8 + 32
c = t
elif d == 'k':
c = t - 273.15
f = t*1.8 - 459.67
k = t
elif d == 'f':
k = (t+459.67)/1.8
c = (t-32)/1.8
f = t
print(f'{c:.2f} C\n{k:.2f} K\n{f:.2f} F')
else:
print('incorect input')
Comments
Leave a comment