This code converts a temperature in Celsius to Fahrenheit.
The first line prompts the user to enter the temperature in Celsius, which is stored in the variable
The next line performs the conversion of the Celsius temperature to Fahrenheit. The conversion formula is
F = C * 1.8 + 32, where
F is the temperature in Fahrenheit and
C is the temperature in Celsius. The result is stored in the variable
The last line prints the temperature in Fahrenheit, using the
f to a string using the
str function, so that it can be concatenated with the string “Temperature in fahrenheit: “.
c = float(input("Please enter temperature in celsius: ")) f = c * 1.8 + 32 print("Temperature in fahrenheit: " + str(f))
Please enter temperature in celsius: 10 Temperature in fahrenheit: 50.0