I am going to write down this pseudocode in python:
if (i < .1):
doX()
elif (i < .3):
doY()
elif (i < .5):
doZ()
.
.
else:
doW()
The range of numbers may be 20, and each float number which shapes the constraints is read from a list. For the above example (shorter version), it is the list:
[0.1, 0.3, 0.5, 1]
Is there any pythonic way or a function which can do different functions for different associated ranges?
Aucun commentaire:
Enregistrer un commentaire