+ 1

How to convert celsius to fahrenhite by using python language

5th Sep 2023, 10:57 AM
Muskan Singla
4 Respuestas
+ 8
Muskan Singla , please show us your attempt first. put your code in playground and save it. then create a link to it and post it here.
5th Sep 2023, 11:07 AM
Lothar
Lothar - avatar
+ 7
Muskan Singla , if you are going to use your code with *code coach*, you should output only what is requested in the task description any other output (eg. in input() function) will cause problems and does not pass the test cases.
5th Sep 2023, 5:44 PM
Lothar
Lothar - avatar
+ 2
Temperature=int(input("enter temperature")) if unit.lower() == 'c': converted_temperature = (temperature * 9/5) + 32 converted_unit = 'Fahrenheit' elif unit.lower() == 'f': converted_temperature = (temperature - 32) * 5/9 converted_unit = 'Celsius' print("\nConverted temperature: {:.2f} {}".format(converted_temperature, converted_unit))
5th Sep 2023, 11:18 AM
Muskan Singla
+ 2
There are a couple of errors here to work thru. 1. Python is a case sensitive language. 'Temperature' should not be capitalized since it is referenced as lowercase later in the code. 2. The variable 'unit' has not been declared. 3. The if statement is not going to work since the input has been converted to an integer and you are searching for an alpha character.
5th Sep 2023, 11:59 AM
Keith
Keith - avatar