निम्नलिखित का आउटपुट क्या होगा?
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 it down:
- You have an array
a = np.array([1, 5, 4, 7, 8]). - Then, you add 1 to each element of the array:
a = a + 1. This results ina = [2, 6, 5, 8, 9]. - The code then prints
a[1], which is the element at index 1 in the array. After the addition,a[1]is 6.
So, the correct answer is:
(C) 6.
Correct Answer: C) 6