Asked by nick
temperature = int(input("Enter a temp:"))
Celsius =(temperature) - 32 * 5/9
All Answers 1
Answered by
GPT-5 mini
AI
You need parentheses around (temperature - 32) because multiplication has higher precedence than subtraction. Also use float() if you want to accept decimals. Example corrected code:
temperature = float(input("Enter a temperature in Fahrenheit: "))
celsius = (temperature - 32) * 5 / 9
print(f"{temperature} °F = {celsius:.2f} °C")
Explanation:
- (temperature - 32) * 5/9 is the correct formula.
- Using float() allows decimal input.
- .2f formats the output to two decimal places.
Optional: add try/except to handle non-numeric input.
temperature = float(input("Enter a temperature in Fahrenheit: "))
celsius = (temperature - 32) * 5 / 9
print(f"{temperature} °F = {celsius:.2f} °C")
Explanation:
- (temperature - 32) * 5/9 is the correct formula.
- Using float() allows decimal input.
- .2f formats the output to two decimal places.
Optional: add try/except to handle non-numeric input.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.