Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing random integer values solution in NumPy exercises #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gideonjeffrey
Copy link

Wonderful tutorials but I've noticed this problem. When prompted:

###Create a numpy array, filled with 3 random integer values between 1 and 10.

The listed solution is

np.random.randint(10, size=3)

But this code will produce a numpy array of size 3 with integer values between 0 and 10, not 1 and 10.

The returned array differs each time, of course, but the first time running the solution code in my notebook returned array([0, 4, 0]).

Instead, the solution code should be

np.random.randint(1, 10, size=3)

to specify 1 as the low value (inclusive) and 10 as the high value (exclusive). I'm ignoring the ambiguity of "between" in the prompt here, but perhaps clarifying inclusive/exclusive would be helpful too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant