I'm new to Python and stuck on this code to convert Celsius to Fahrenheit. I have to use sys.argv and print out the corresponding Fahrenheit value to two decimals. Although, it does not give me an error, the answer is incorrect because the output is always 1 decimal.
Here's my code:
import sys
def TempCtoF(Celsius):
Celsius = float(Celsius)
Fahrenheit = float((9/5 * Celsius)+ 32)
return Fahrenheit
Celsius = sys.argv[1]
Fahrenheit = TempCtoF(Celsius)
print("The temperature is", round(Fahrenheit, 2),"degrees Fahrenheit.")
Expected output:
The temperature is 73.40 degrees Fahrenheit.
Actual output:
The temperature is 73.4 degrees Fahrenheit.
However, it seems to be correct when the temperature is in the 3 digits.
Expected output:
The temperature is 132.03 degrees Fahrenheit.
Actual output:
The temperature is 132.03 degrees Fahrenheit.
I am not quite sure how to fix this. Please help!