What You'll Learn
- •Using temperature conversion formulas
- •Working with arithmetic expressions
- •Handling decimal numbers in calculations
Python
# Program to convert Celsius to Fahrenheit
celsius = float(input("Enter temperature in Celsius: "))
# Formula: F = (C * 9/5) + 32
fahrenheit = (celsius * 9/5) + 32
print(celsius, "°C is equal to", fahrenheit, "°F")Output
Enter temperature in Celsius: 25 25.0 °C is equal to 77.0 °F
Convert Celsius to Fahrenheit in Python
We use the standard temperature conversion formula:
F = (C × 9/5) + 32
Where:
- F = temperature in Fahrenheit
- C = temperature in Celsius
Understanding the Formula
The formula converts Celsius to Fahrenheit:
- Multiply Celsius by 9/5 (or 1.8)
- Add 32 to the result
Example
If you have 25°C:
- F = (25 × 9/5) + 32
- F = (25 × 1.8) + 32
- F = 45 + 32 = 77°F
Program Logic
pythoncelsius = float(input("Enter temperature in Celsius: ")) fahrenheit = (celsius * 9/5) + 32 print(celsius, "°C is equal to", fahrenheit, "°F")
Key Takeaways
1
Formula: F = (C × 9/5) + 32
2
Use float for decimal temperatures
3
This is the reverse of Fahrenheit to Celsius conversion
4
Common in weather applications and scientific calculations
Step-by-Step Breakdown
- 1Read temperature in Celsius from the user.
- 2Apply the conversion formula: F = (C × 9/5) + 32.
- 3Store the result in fahrenheit variable.
- 4Print both Celsius and Fahrenheit values.