Python Program - Convert Celsius To Fahrenheit
here's a Python program that converts Celsius to Fahrenheit:
# get input from user celsius = float(input("Enter temperature in Celsius: ")) # calculate temperature in Fahrenheit fahrenheit = (celsius * 9/5) + 32 # print the result print(celsius, "Celsius = ", fahrenheit, "Fahrenheit")Sour:ecwww.theitroad.com
In this program, we first use the input()
function to get input from the user, and store it in the variable celsius
. We also use the float()
function to convert the user's input from string to float.
We then use the formula F = (C * 9/5) + 32
to convert the temperature from Celsius to Fahrenheit, and store the result in the variable fahrenheit
.
Finally, we use the print()
function to print out the original temperature in Celsius and the converted temperature in Fahrenheit.