2/24/19, 11(55 PMlab05_masterIn Python, the boolean data type contains only two unique values:TrueandFalse. Expressionscontaining comparison operators such as<(less than),>(greater than), and==(equal to) evaluate toBoolean values. A list of common comparison operators can be found below!Run the cell below to see an example of a comparison operator in action.In [2]:3 > 1 + 1We can even assign the result of a comparison operation to a variable.In [3]:result= 10 / 2 == 5resultOut[2]:TrueOut[3]:
Get answer to your question and much more
Page 2 of 34Arrays are compatible with comparison operators. The output is an array of boolean values.In [4]:make_array(1,5,7,8,3,-1One day, when you come home after a long week, you see a hot bowl of nachos waiting on the dining table!Let's say that whenever you take a nacho from the bowl, it will either have onlycheese, onlysalsa,bothcheese and salsa, orneithercheese nor salsa (a sad tortilla chip indeed).Let's try and simulate taking nachos from the bowl at random using the function,np.random.choice(...).np.random.choicenp.random.choicepicks one item at random from the given array. It is equally likely to pick any of theitems. Run the cell below several times, and observe how the results change.Out[4]:array([False,True,True,True, False, False]))> 3