Data Analysis with Python Course - Numpy Operations
What is the value of a after you run the following code?
a = np.arange(5)
a + 20
A [20, 21, 22, 24, 24]
B [0, 1, 2, 3, 4]
C [25, 26, 27, 28, 29]
The correct answer is array([20, 21, 22, 23, 24]) isn't it?
Hi and welcome to the forum.
The second line does not change the values in a.
Hi thanks for reply ! Can you explain in details? I cant understand why
The code
a + 20
does not store anything into a.
There is no assignment operator, =
I see, if the code is
a = np.arange(5)
a= a + 20
then the answer is array([20, 21, 22, 23, 24]) ?
Exactly! Without that = the computation is executed and discarded
1 Like