Q:

Write a NumPy program to test whether a given 2D array has null columns or not

0

Write a NumPy program to test whether a given 2D array has null columns or not.

All Answers

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

import numpy as np
print("Original array:")
nums = np.random.randint(0,3,(4,10))
print(nums)
print("\nTest whether the said array has null columns or not:")
print((~nums.any(axis=0)).any())

Sample Output:

Original array:
[[1 2 1 1 1 2 1 1 2 0]
 [1 1 0 0 0 0 2 1 2 0]
 [0 0 2 1 0 2 2 2 2 2]
 [1 1 1 2 0 0 0 0 1 2]]

Test whether the said array has null columns or not:
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