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.
Below is the complete Temperature Converter program:
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 9/5) + 32
print("Temperature in Fahrenheit:", fahrenheit)
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.
F = (C × 9/5) + 32
For example, entering 100 (boiling point of water) outputs:
Temperature in Fahrenheit: 212.0
Enter temperature in Celsius: 0 Temperature in Fahrenheit: 32.0
input() functionprint() functionfloat() for decimal valuesThe 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
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.