Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water boils at 100 degree C and freezes as 0 degree C, use the program to find out what is the boiling point and freezing point of water on the Fahrenheit scale. (Hint: T(°F) = T(°C) × 9/5 + 32)
#Program to convert Celsius to Fahrenheit celsius = float(input("Enter temperature in Celsius: ")) fahrenheit = celsius * 9/5 + 32 print("Temperature in Fahrenheit:", fahrenheit)
#Finding boiling point (100°C) celsius_boil = 100 fahrenheit_boil = celsius_boil * 9/5 + 32 print("Boiling point of water:", fahrenheit_boil, "°F")
#Finding freezing point (0°C) celsius_freeze = 0 fahrenheit_freeze = celsius_freeze * 9/5 + 32 print("Freezing point of water:", fahrenheit_freeze, "°F")
Output: Boiling point of water: 212.0 °F Freezing point of water: 32.0 °F
Explanation: The program uses the formula T(°F) = T(°C) × 9/5 + 32 to convert temperature from Celsius to Fahrenheit. For the boiling point at 100°C, the calculation is: /5 + 32 = 180 + 32 = 212°F. For the freezing point at 0°C, the calculation is: /5 + 32 = 0 + 32 = 32°F. The program demonstrates how arithmetic operators and variables work together to perform mathematical conversions.
Explanation
This question tests the student's understanding of arithmetic operations and formula implementation in Python. The formula T(°F) = T(°C) × 9/5 + 32 is provided in the hint. Students should write a program that takes Celsius as input, applies the conversion formula, and outputs the Fahrenheit value. For the specific values: 100°C converts to 212°F (boiling point) and 0°C converts to 32°F (freezing point). The context mentions explicit type conversion and arithmetic operations which are relevant concepts here.
Solution Steps
Step 1: Accept temperature in Celsius using input() function
Step 2: Apply the conversion formula: fahrenheit = celsius * 9/5 + 32
Step 3: For boiling point (100°C): /5 + 32 = 180 + 32 = 212°F
Step 4: For freezing point (0°C): /5 + 32 = 0 + 32 = 32°F
Step 5: Display the results using print() function