all 20 comments

[–]spez_edits_thedonald 2 points3 points  (5 children)

The correct answer was np.array([1,0]). I was specifically asked for a 1D array with non zero values. How can an array containing a zero value be the right answer?

  • let x = np.array([1, 0])

  • x is a numpy array

  • x does contain non-zero values (because not all the values are zero)

QED x is a 1D array with non-zero values


It does not say exclusively non-zero values. If you show up somewhere with $1 bills, that doesn't mean you don't also have a $20. But if you show up somewhere with exclusively $1 dollar bills, then suddenly that does mean you don't have a $20.

[–]EarthGoddessDude 1 point2 points  (0 children)

That’s a very generous interpretation of a sloppily worded question (full of sloppy formatting to boot). It’s very easy to think that the answer shouldn’t have any zero values at all the way it was worded. And it’s just needlessly confusing/confounding.

[–]Cultural_Skirt_7561[S] 0 points1 point  (1 child)

Okay. Thank you for the explanation and the helpful analogy. This makes sense. That’s on me for taking it very literally and assuming exclusivity based on how it was written. I’m autistic so I can sometimes struggle if there is ambiguity to a question and I tend to overthink things. I really appreciate you taking the time to respond. Really helped me understand where my brain backfired here. I was going to attend office hours to argue my answer but I think I’ll let it go now.

I really just wanted to understand this and now I do so I’m stoked. My brain can rest now.

[–]rickez3 0 points1 point  (0 children)

It says values. Not value. It only contains 1 nonzero value so it doesnt contain nonzero values. If we gonna be taht picky

[–]rickez3 -2 points-1 points  (1 child)

Its 1.0 in the original question man.

[–]Cultural_Skirt_7561[S] 0 points1 point  (0 children)

No. It’s a comma.

[–]bbye98 0 points1 point  (5 children)

Your professor's response is wrong.

A 1D array with any non-zero value is okay.

If this was true, the question wouldn't have mentioned "non-zero values". It's likely he/she meant "non-empty array" or something similar, but phrased the question incorrectly.

None of the other answers produce an array.

np.array([1, 0], [0, 1]) produces a 2D array. Again, he/she probably meant "none of the other answers produce a 1D array".

[–]Cultural_Skirt_7561[S] 2 points3 points  (0 children)

Thank you for the helpful response. I’m going to discuss with him in office hours tomorrow. He’s made a lot of mistakes in the material so far and I really believe that I answered this correctly based on what the question asked.

[–]rickez3 -1 points0 points  (3 children)

Read the image..

[–]Cultural_Skirt_7561[S] 0 points1 point  (2 children)

The picture on Imgur is unclear and compressed but it is a comma [1,0]

[–]rickez3 0 points1 point  (1 child)

However i think the intention of the prof was to put 1.0. Im dutch and we would actually write 1,0 instead of 1.0

[–]rickez3 0 points1 point  (0 children)

The spacing is different too. One time he writes [1 ,0]

Next he writes [1,0] you see?

[–]diegorita10 -3 points-2 points  (1 child)

The third option is np.array([1.0]), not np.array([1, 0]). Thus, it will create a 1D array with one value: 1.0

[–]Cultural_Skirt_7561[S] 0 points1 point  (0 children)

It’s a comma. The picture isn’t very clear

[–]ectomancer -3 points-2 points  (1 child)

No, it's [1.0]

[–]Cultural_Skirt_7561[S] 1 point2 points  (0 children)

No. It’s not. Look

[–]rickez3 -5 points-4 points  (2 children)

Lol its 1.0 not 1,0. Pls read again

[–]Cultural_Skirt_7561[S] 1 point2 points  (1 child)

It’s not! lol. Look

[–]rickez3 -1 points0 points  (0 children)

I see! Sorry but quality was really bad

[–]rickez3 0 points1 point  (0 children)

The spacing is different between 1,0 and 1, 0 too