0
I dont know how to integrate these:
I have written the function for the code and the loop is also ok but what i dont know is how to and where to put the conditions,if the result of the calculation is a number between 82-87 degrees celcius then the code should break and welcome the user to the sauna, otherwise it should say ”wrong input, try again” and the loop would continue. https://code.sololearn.com/cmcFaKqvE0Q8/?ref=app
13 Antworten
+ 2
Lenoname
Yes range doesn't works on floating numbers.
The other way is you can Numpy arange function:
import numpy as np
np.arange (start, stop, step)
+ 1
Lenoname
Yes this value you have returned in a function so if you want to use returned value then do like this:
temp = fahr_to_cel(fah)
now compare temp to given range 82 - 87
if temp >= 82 and temp <= 87:
print()
0
Lenoname
We use return in two ways:
1 - just return
2 - return a value
So if you return a value inside function then returned value should be store in a variable if you want to use that variable at another place.
So store your return value and use that returned value
0
A͢J isnt this what u mean?the value is in a variable:
y = (fah-32)*5 / 9
No?
0
FF9900 the first print after the if statement is only for the wrong numbers right?
0
A͢J modified the code plz check again, the right answer is ok but if i put the wrong one i get multiple unwanted things printed out
0
FF9900 The code works very well, but what are sys and exit? Any alternatives to these?
0
FF9900 one more thing, if the value returned is a floating number and not an integer, how would you test wether it existed between 82-87 or not? If c in range(82,88) wouldnt work.
0
Nothing to do really with the code itself, but with the meaning of the code: why do you ask for an input in deg celsius, while your function converts farenheit to celsius? Shouldn't the input be done in farenheit?