This video has three solutions. I do not believe any of them are correct…
Is the solution [20, 21, 22, 23, 24] ??
This video has three solutions. I do not believe any of them are correct…
Is the solution [20, 21, 22, 23, 24] ??
Take a closer look at the code, correct answer is definitely among the options.
Hello there,
I recommend you run the code to test it, and convince yourself of the answer:
Hope this helps.
It doesn’t I can’t figure out how to download/install numpy.
I am using Pycharm and had problems with numpy see here
I did what they said and ran
C:\Users\DrMan\AppData\Local\Programs\Python\Python39\venv\Scripts>pip install numpy==1.19.3
to get the previous version of numpy installed (removing 1.19.4) which sounds like it will be fixed in January?
when I run your code snippet I get
[0,1,2,3,4] i.e. the +20 had no effect
import numpy as np
a = np.arange(5)
print(a)
a + 20
print(a)
[0 1 2 3 4]
[0 1 2 3 4]
of course if you change the line to
a = a + 20 you would get the result you quoted.
you can just run the code in the repl
Ahh yes, this question fooled me too
here is what you need to know, there is a big difference between assigning a value and working on a copy of a value
a = np.arange(5)
a + 20
in this case we are working with a copy of “a” and “a” is not being reassigned to a different value(using “=”)so the value of “a” shouldnt change at all.
if it was
a = a + 20
it would have been a different story
i hope my explanation was clear
oh ok that makes sense. Thanks doc