निम्नलिखित का आउटपुट क्या होगा?
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
4
B
5
C
6
D
7
Explanation
Let's break down the code:
- The array
ais created with the values[1, 5, 4, 7, 8]. - The operation
a = a + 1increments 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.
Correct Answer: C) 6