(Oct-18-2020, 03:26 PM)TheLowEndTheory Wrote: If I dont have the "return" and the cel, fah, kel, the program won't be able to return the calculation to convert the temperature type and the number that the user had input
Note I refer only to
displayResults
function.def displayResults(cel, fah, kel): print("Celsius =", cel) print("Fahrenheit =", fah) print("Kelvin =", kel) return cel and fah and kelYour function just prints the arguments you pass. It does not need to return anything, nor you use what it currently returns. On line 65 you just call it
displayResults(cel, fah, kel)
. You don't assign what it returns to anything and simply throw it away.Now the other problem, look at the return statement:
return cel and fah and kel
cel
, fah
and kel
are floats. So if all 3 variables can be evaluated as True, it will return kel
. If any of cel
or fah
is 0
or 0.0
, i.e. that is evaluated as True, it will return it.>>> 1 and 2 and 3 3 >>> 1 and 0.0 and 2 0.0read more here https://docs.python.org/3.8/library/stdtypes.html#truth
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs