Answer to Question #281060 in Python for Bhargavi

Question #281060

Temperature conversion in


Program

1
Expert's answer
2021-12-20T09:59:44-0500
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')

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