🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित कोड के लिए आउटपुट क्या होगा?

What will be output for the following code ?

import numpy as np
ary = np.array([1,2,3,5,8])
ary = ary + 1
print (ary[1])
A)
B)
C)
D)

Explanation:

Let's analyze the code:

import numpy as np
ary = np.array([1, 2, 3, 5, 8])
ary = ary + 1
print(ary[1])

Step-by-step breakdown:

  1. ary = np.array([1, 2, 3, 5, 8]): Creates a NumPy array with elements [1, 2, 3, 5, 8].
  2. ary = ary + 1: Adds 1 to each element of the array. This will give [2, 3, 4, 6, 9].
  3. print(ary[1]): Prints the element at index 1 of the modified array, which is 3.

So, the output will be:

3

Answer: (D) 3.

Latest Updates