Use python to convert temperature from Fahrenheit to Celsius

 

>>> temp = float(input("Enter temperature in Fahrenheit: "));
Enter temperature in Fahrenheit: 100
>>> celsius = (temp - 32) * 5/9
>>> print(f"{temp}F = {celsius}C")
100.0F = 37.77777777777778C
>>> 

 

Or, to express it as a whole number:

 

def fahrenheit_to_celsius_whole(fahrenheit):

    celsius = (fahrenheit - 32) * 5/9

    return round(celsius)

 

fahrenheit_input = float(input("Enter temperature in Fahrenheit: "))

celsius_result = fahrenheit_to_celsius_whole(fahrenheit_input)

print(f"{fahrenheit_input} degrees Fahrenheit is {celsius_result} degrees Celsius")

 

RESULTS:

 

Enter temperature in Fahrenheit:

100

100.0 degrees Fahrenheit is 38 degrees Celsius

 

Go Back