Q:

Write a NumPy program to check two random arrays are equal or not

0

Write a NumPy program to check two random arrays are equal or not.

All Answers

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

import numpy as np
x = np.random.randint(0,2,6)
print("First array:")
print(x)
y = np.random.randint(0,2,6)
print("Second array:")
print(y)
print("Test above two arrays are equal or not!")
array_equal = np.allclose(x, y)
print(array_equal)

Sample Output:

First array:                                                           
[1 0 0 0 1 0]                                                          
Second array:                                                          
[0 0 1 1 0 1]                                                          
Test above two arrays are equal 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