Answer to Question #176586 in Python for adhi chinna

Question #176586

Temperature Conversion

You are given the temperature T of an object in one of Celsius, Fahrenheit, and Kelvin scales.

Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.

Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.

Formula to convert from Kelvin K to Celsius C is C = K - 273.

Here "C", "F", "K" represent that the temperature scale is in Celsius, Fahrenheit and Kelvin scales respectively.

The input contains the temperature (a number) and the unit of the temperature scale (C, F, K) without any space.

The output contains temperature in Celsius, Fahrenheit and Kelvin scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places


1
Expert's answer
2021-03-29T22:41:42-0400

 format similar to input and the value of the temperature is rounded to 2 decimal places.


Expert's answer

T = input("Enter the Temperature(T) and Scale(C,F,K) without any space: ")


S=T[-1]
T=T[0:len(T)-1]
T=int(T)




# When Scale is Celsius
if S=='C':
	F=(9/5)*int(T) + 32
	print("Temerature in Celsius",T)
	print("Temerature in Kelvin",(int(T)+273))
	print("Temerature in Fahrenheit",F)


# When Scale is Fahrenheit
elif S=='F':
	C=(int(T)-32)*(5/9)
	K=C+273
	print("Temerature in Fahrenheit",T)
	print("Temerature in Celsius",round(C,2))
	print("Temerature in Kelvin",round(K,2))


# When Scale is Kelvin
elif S=='K':
	C=int(T)-273
	F=(9/5)*int(C) + 32
	print("Temerature in Kelvin",T)
	print("Temerature in Celsius",round(C,2))
	print("Temerature in Fahrenheit",round(F,2))


else: 
	print("Rerun the program and Enter the valid Choice")

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
APPROVED BY CLIENTS