Q:

Write a NumPy program to check whether a Numpy array contains a specified row

0

Write a NumPy program to check whether a Numpy array contains a specified row.

All Answers

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

import numpy as np
num = np.arange(20)
arr1 = np.reshape(num, [4, 5])
print("Original array:")
print(arr1)
print([0, 1, 2, 3, 4] in arr1.tolist())
print([0, 1, 2, 3, 5] in arr1.tolist())
print([15, 16, 17, 18, 19] in arr1.tolist())

Sample Output:

Original array:
[[ 0  1  2  3  4]
 [ 5  6  7  8  9]
 [10 11 12 13 14]
 [15 16 17 18 19]]
True
False
True

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