Doubt In Question 5

How do we get the given output in ques5?

Hey @amoghjalan2005, let me explain you. So in this question, we are given a list as :

dataset = np.array(['paul', 'jacob', 'vince', 'paul', 'miky', 'jacob', 'warren'])

Now we need to tell the output of :
new_var = (dataset == 'paul') | (dataset == 'jacob') which means that we check for “paul” and “jacob” in the whole dataset one by one starting from the 0th index. So we check that whether dataset[0] is either of ‘paul’ or ‘jacob’. If the condition is true, the output returned is true. Similarly, for dataset[1], the condition is again true. But for dataset[2] the condition becomes false (as dataset[2] is neither ‘jacob’ nor ‘paul’) and hence a false is returned. Similarly if you check for all the indices in the dataset, you would get the final answer as :

[ True True False True False True False]

I hope this clears your doubt !
Please mark the doubt as resolved in your doubts section ! :slight_smile:
Happy Learning ! :slightly_smiling_face: