25.0C
77.0F
298.0K
this is expecetd output and when i enterded 37.5F iam getting value error
ValueError: invalid literal for int() with base 10: '37.5
First, you enter is a float number, so you should use a float() function instead of an int(). Second, what you enter is not a literal for float number, so you need to parse it.
s = input()
val = float(s[:-1])
m = s[-1]
if m == 'C':
print(s)
print((val*9/5)+32, end='F\n')
print(273.0+val, end='K\n')
elif m == 'F':
c = (val-32)*5/9
print((val-32)*5/9, end='C\n')
print(s)
print(c, end='K\n')
else:
c = val - 273
print(c, end='C\n')
print((c*9/5)+32, end='F\n')
print(s)
Comments
Leave a comment