Q:

Write a NumPy program to test whether each element of a 1-D array is also present in a second array

0

Write a NumPy program to test whether each element of a 1-D array is also present in a second array

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
array1 = np.array([0, 10, 20, 40, 60])
print("Array1: ",array1)
array2 = [0, 40]
print("Array2: ",array2)
print("Compare each element of array1 and array2")
print(np.in1d(array1, array2))

Sample Output:

Array1:  [ 0 10 20 40 60]                                              
Array2:  [0, 40]                                                       
Compare each element of array1 and array2                              
[ True False False  True False]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now