0

Please help me with Celsius to Fahrenheit Test i found older questions but i tried those and does not work

celsius = int(input()) def conv(c): #your code goes here def conv(c): fahrenheit = (celsius * 9/5) + 32 return: fahrenheit fahrenheit = conv(celsius) print(fahrenheit) Does not work either syntax error either indent or something help pls

21st May 2021, 6:28 PM
Vlad MDMA
Vlad MDMA - avatar
3 odpowiedzi
+ 2
1) don't repeat the "def conv(c):" line inside the function 2) don't put colon after "return" keyword also, as you pass the "celcius" variable to the function as "c" argument, you should use "c" rather than "celcius" inside function (even if in this case that would work)... celsius = int(input()) def conv(c): #your code goes here fahrenheit = (c * 9/5) + 32 return fahrenheit fahrenheit = conv(celsius) print(fahrenheit)
21st May 2021, 6:53 PM
visph
visph - avatar
+ 1
Thank you
21st May 2021, 7:02 PM
Vlad MDMA
Vlad MDMA - avatar
+ 1
it's also possible to pass the return value of conv(celcius) directly as print() argument, without using the global variable "farenheit": print(conv(celcius)) and you could avoid "celcius" global variable by passing int(input()) return value as conv() argument: print(conv(int(input()))) ... but be careful to not forgot (or add) closing parenthesis, and remove the first "celcius" assignement: with two input() call inside your script, it will not work as expected ^^
21st May 2021, 7:15 PM
visph
visph - avatar