Working on a set of problems and I have come across syntax that I haven't seen before. can someone explain line 4 to me what it reads in English? Is this the standard syntax to communicate range? Why isn't 15 first?
Here is the problem.
-
Define a function that takes a temperature as a parameter.
-
returns "Hot" if the temperature is greater than 25
-
Returns "warm" if the temperature is between 15 and 25 including 15 and 25
-
Returns "cold" if the temperature is less than 15
def temperature(temp):
if temp > 25:
return 'Hot'
elif 25 >= temp >= 15:
return 'Warm'
else:
return 'Cold'
Aucun commentaire:
Enregistrer un commentaire