Q:

Create a result array by adding the following two NumPy arrays. Next, modify the result array by calculating the square of each element

belongs to collection: Python NumPy Exercises

0

Create a result array by adding the following two NumPy arrays. Next, modify the result array by calculating the square of each element

arrayOne = numpy.array([[5, 6, 9], [21 ,18, 27]])
arrayTwo = numpy.array([[15 ,33, 24], [4 ,7, 1]])

Expected Output:

addition of two arrays is 

[[20 39 33]
 [25 25 28]]

Result array after calculating the square root of all elements

[[ 400 1521 1089]
 [ 625  625  784]]

All Answers

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

import numpy

arrayOne = numpy.array([[5, 6, 9], [21 ,18, 27]])
arrayTwo = numpy.array([[15 ,33, 24], [4 ,7, 1]])

resultArray  = arrayOne + arrayTwo
print("addition of two arrays is \n")
print(resultArray)

for num in numpy.nditer(resultArray, op_flags = ['readwrite']):
   num[...] = num*num
print("\nResult array after calculating the square root of all elements\n")
print(resultArray)

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

total answers (1)

Split the array into four equal-sized sub-arrays u... >>
<< Return array of odd rows and even columns from bel...