Answer to Question #165049 in Python for B Mani teja

Question #165049
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


1
Expert's answer
2021-02-21T19:52:11-0500

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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS