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

Answer for numpy exercise concerning numpy.any is incorrect #6

Open
alma-pi opened this issue Mar 24, 2021 · 2 comments
Open

Answer for numpy exercise concerning numpy.any is incorrect #6

alma-pi opened this issue Mar 24, 2021 · 2 comments

Comments

@alma-pi
Copy link

alma-pi commented Mar 24, 2021

In '3. NumPy exercises.ipynb' under Logic functions, the example for any is incorrect: X.any returns True even if there are no zeros.

Since the fix depends on the intent/goal of the question, there are different ways of fixing it, for example:

  1. Keeping the question identical and changing the answer:
# Given the X numpy array, return True if any of its elements is zero
X = np.array([-1, 2, 0, -4, 5, 6, 0, 0, -9, 10])
np.any(X==0)
  1. Keeping the answer identical and changing the question:
# Given the X numpy array, return True if any of its elements is true
X = np.array([-1, 2, 0, -4, 5, 6, 0, 0, -9, 10])
X.any()
@aldeeorbs
Copy link

I was about to raise this issue as well. Thanks.

@Priteshs375
Copy link

"Given the X numpy array, return true if any of its element is non-zero."

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

No branches or pull requests

3 participants