The question given is fine, but i guess the answer to that is wrong. Please check and let me know, Coz the answer should be
[20,21,22,23,24]
but it says
[0,1,2,3,4] is the right anser.
what’s the question you are talking about?
What is the value of a
after you run the following code?
a = np.arange(5)
a + 20
The answer should be
[20,21,22,23,24] , right?
but it says [0,1,2,3,4] is the right answer
add print(a)
below and execute it
The answer [0,1,2,3,4] is correct, because doing a + 20 will return the array [20, 21, 22, 23, 24] but won’t assign it to a (that’s the tricky part of the question). The + operation by itself is immutable. In order to assign the result to a, you’d have to use the += operator.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.