Temperature Converter Program

This page explains a Temperature Converter program written in Python. The program converts a temperature value from Celsius to Fahrenheit using a simple mathematical formula. This type of program is a classic example used in introductory CS courses because it demonstrates variables, arithmetic operations, and output in a clear and practical way.

The Program

Below is the complete Temperature Converter program:

celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 9/5) + 32
print("Temperature in Fahrenheit:", fahrenheit)

How the Program Works

The key variable is celsius, which stores the user's input. A second variable, fahrenheit, stores the converted result. The float() function converts the input to a decimal number.

The Formula

F = (C × 9/5) + 32

For example, entering 100 (boiling point of water) outputs:

Temperature in Fahrenheit: 212.0

Sample Output

Enter temperature in Celsius: 0
Temperature in Fahrenheit: 32.0

Key Concepts

Why This Program Is Useful

The US uses Fahrenheit while most of the world uses Celsius. This converter solves a real everyday problem. According to Web Programming with HTML, CSS, and JavaScript by John Dean, understanding input and output is a foundational skill for all developers.

"First, solve the problem. Then, write the code."
— John Johnson

Conclusion

This program takes user input, applies a formula using celsius and fahrenheit, and displays the result. It is a simple but complete example of how programs work.


Web Programming with HTML, CSS, and JavaScript — Chapter 2 Project