Answer to Question #232445 in Python for Lovely

Question #232445

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


1
Expert's answer
2021-09-03T00:09:58-0400
i = input("Enter the temperature : ")


if i[-1] == "k" or i[-1] == "K":
    x = int(i[:-1])
    c = x - 273
    k = x
    f = (9*c/5) + 32
    print("Temperature in Celcius is :",c," C") 
    print("Temperature in Kelvin is :",k," K") 
    print("Temperature in Fahrenheit is :",f," F") 




   
if i[-1] == "c" or i[-1] == "C":
    x = int(i[:-1])
    c = x
    k = x + 273
    f = (9*c/5) + 32
    print("Temperature in Celcius is :",c," C") 
    print("Temperature in Kelvin is :",k," K") 
    print("Temperature in Fahrenheit is :",f," F") 






if i[-1] == "f" or i[-1] == "F":
    x = int(i[:-1])
    c = (x-32)*5/9
    k = c + 273
    f = x
    print("Temperature in Celcius is :",c," C") 
    print("Temperature in Kelvin is :",k," K") 
    print("Temperature in Fahrenheit is :",f," F") 

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