Question 13

What will the following code result in? A = np.array ([12, 23])

What will the following code result in? import numpy as np A = np.array ([12, 23]) B = np.array ([10, 20]) print (A-B)
  1. A[-2 -3]
  2. B[[12 23] [10 20]]
  3. C[[10 20] [12 23]]
  4. D[2 3]
Show answerHide answer

Correct answer: (D) [2 3]

Explanation

NumPy subtracts arrays element by element: [12−10, 23−20] = [2 3]. It does not stack or combine the arrays.

From DSSSB TGT Computer Science Practice Set 1

This is question 13 of DSSSB TGT Computer Science Practice Set 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.