On the assignment question after the Numpy Operations video the answer is wrong.
The question asks which is going to be the value of “a” after this statements:
a = np.arange(5)
a + 20
The answer shown as correct is option 2:
[0, 1, 2, 3, 4]
The correct answer is option 1:
[20, 21, 22, 24, 24]
Have you tried executing these lines in python interpreter?
It was not necessary because as you can see there is no reason why np.arange(5) is going to generate the array [-20,-19,-18,-17,-16]
But, yes I did it before posting.
That screen though doesn’t show the value of a
at the end.
1 Like
‘a + 20’ is a broadcasting operation and will not change the original array. ‘a += 20’ would change it.
system
Closed
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.