निम्नलिखित कोड का परिणाम क्या है?
What is the output of the following code?
import numpy as np
a = np.array([1,2,3,5,8])
b = np.array([0,1,5,4,2])
c = a + b
c = c*a
print (c[2]) A
6
B
24
C
1
D
None of these
Explanation
Let's simplify the explanation:
-
Arrays:
a = [1, 2, 3, 5, 8] b = [0, 1, 5, 4, 2] -
Adding arrays
aandb:c = a + b # [1+0, 2+1, 3+5, 5+4, 8+2] = [1, 3, 8, 9, 10] -
Multiplying
cbya:c = c * a # [1*1, 3*2, 8*3, 9*5, 10*8] = [1, 6, 24, 45, 80] -
Print the third element (
c[2]):print(c[2]) # This is 24
Output: 24
Answer: (B) 24
Correct Answer: B) 24