Monday, July 29, 2019

Centigrade to Fahrenheit conversion and vice versa

Script

#!/usr/local/bin/python3.1

celsius = float(input("Enter the degrees in Celsius: "))

fahrenheit = 9.0/5.0 * celsius + 32

print ("The temperature in Fahrenheit is: ", fahrenheit)

print ()
print ()

fahrenheit = float(input("Now enter the degrees in Fahrenheit: "))

celsius = (fahrenheit - 32) * 5.0/9.0

print ("The temperature in Celsius is: ", celsius)



Execution

Enter the degrees in Celsius: 100
The temperature in Fahrenheit is:  212.0


Now enter the degrees in Fahrenheit: 212
The temperature in Celsius is:  100.0





Enter the degrees in Celsius: 125.48
The temperature in Fahrenheit is:  257.864


Now enter the degrees in Fahrenheit: 300
The temperature in Celsius is:  148.888888889





No comments:

Post a Comment