Tell us what’s happening:
The command:
“a = np.arange(5)” results in an array that contains (0,1,2,3,4)
Now, When do the operation:
“a+20” , each element of the array should be incremented by 20.
So, the answer should be:
20, 21, 22, 23, 24
but why this the answer (0,1,2,3,4)
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Safari/605.1.15
Challenge Information:
Data Analysis with Python - Numpy Operations
This changes the value of a
because it assigns a value using the =
operator
Does this change the value of a
?
Yes. I have explained well in the question. You see how the value changes from (20,21,22,23,24) to (0,1,2,3,4)
What is the value of a
?
The value doesnt change because there is no = operator on that line.
It might output the updated values in a notebook but the value of the variable ‘a’ is never reassigned.
Honestly this question has tricked me twice before… But never thrice!
system
Closed
5
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.