निम्नलिखित का आउटपुट क्या होगा?
What will be the output of the following?
import numpy as np
a = np.array([1,5,4,7,8])
a = a + 1
print(a[1])
A)
B)
C)
D)
Explanation:
Let's break down the code:
- The array
a
is created with the values[1, 5, 4, 7, 8]
. - The operation
a = a + 1
increments each element of the array by 1. So, the updated array will be[2, 6, 5, 8, 9]
. - When
print(a[1])
is called, it prints the element at index 1 of the updated array, which is6
.
Thus, the correct output is: (C) 6.