Introduction:
In this program, we will be writing a Python program to convert temperature from Celsius to Fahrenheit. The Celsius scale is commonly used in most parts of the world, while the Fahrenheit scale is primarily used in the United States. The conversion formula from Celsius to Fahrenheit is F = (C * 9/5) + 32, where F is the temperature in Fahrenheit and C is the temperature in Celsius.
Algorithm:
- Take input from the user for the temperature in Celsius.
- Convert the input to a floating-point number using the float()
- Apply the conversion formula: F = (C * 9/5) + 32.
- Print the result, formatted to two decimal places, using the format()
Python code:
# Take input from the user
celsius = float(input("Enter temperature in Celsius: "))
# Convert Celsius to Fahrenheit
fahrenheit = (celsius * 9/5) + 32
# Print the result
print("Temperature in Fahrenheit: {:.2f}".format(fahrenheit))
Input :
Enter temperature in celcius : 25
Output :
Enter temperature in Fahrenheit : 77.00