Q:

Write a NumPy program to add two arrays A and B of sizes (3,3) and (,3)

0

Write a NumPy program to add two arrays A and B of sizes (3,3) and (,3).

All Answers

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

import numpy as np
A = np.ones((3,3))
B = np.arange(3)
print("Original array:")
print("Array-1")
print(A)
print("Array-2")
print(B)
print("A + B:")
new_array = A + B
print(new_array)

Sample Output:

Original array:
Array-1
[[1. 1. 1.]
 [1. 1. 1.]
 [1. 1. 1.]]
Array-2
[0 1 2]
A + B:
[[1. 2. 3.]
 [1. 2. 3.]
 [1. 2. 3.]]

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