In this Python program, we will figure out how to change over Fahrenheit to Celsius and Celsius to Fahrenheit?
Formula Used:
Celsius to Fahrenheit: °C= (5/9)*(°F-32)
Fahrenheit to Celsius: °F= (9/5)*(°C) + 32
Code:
# Define a function to convert
# celsius temperature to Fahrenheit
def Celsius_to_Fahrenheit(c) :
f = (9/5)*c + 32
return f
# Define a function to convert
# Fahrenheit temperature to Celsius
def Fahrenheit_to_Celsius(f) :
c = (5/9)*(f - 32)
return c
# Driver Code
if __name__ == "__main__" :
c = 36
print(c, "degree celsius is equal to:",Celsius_to_Fahrenheit(c),"Fahrenheit")
f = 98
print(f,"Fahrenheit is equal to:",Fahrenheit_to_Celsius(f),"degree celsius")
Output:
36 degree celsius is equal to: 96.8 Fahrenheit
98 Fahrenheit is equal to: 36.66666666666667 degree celsius