Answer to Question #329537 in Python for Shubham Tiwari

Question #329537

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


1
Expert's answer
2022-04-18T08:41:16-0400
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")

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