Given a BMI numpy array, let's check which element is fit enough to stand a dessert. Basically, what we want is getting a boolean array where True means that the associated guy has a BMI less than 25. Easier to write the Python code than explain it:
import numpy # ... # given bmis, a numpy array containing BMI for each person under surveillance dessert = bmis < 25Now, if we want to check if Person One could get a slice of cake, we can just check the relative element in the numpy dessert array:
if dessert[1]: print('Enjoy the dessert!') else: print('No dessert for you!')
No comments:
Post a Comment