Master Python For Data Science with 100 free flashcards. Study using spaced repetition and focus mode for effective learning in Data Science.
np.array([1, 2, 3]) converts a Python list into a NumPy ndarray.
np.zeros(5) returns array([0., 0., 0., 0., 0.]).
np.eye(3) returns a 3×3 array with ones on the diagonal and zeros elsewhere.
It returns array([0, 2, 4, 6, 8]) — values from 0 up to (not including) 10 with step 2.
np.linspace(0, 1, 5) returns array([0., 0.25, 0.5, 0.75, 1.]).
arr[1, 2] uses zero-based indexing to retrieve the element at the second row, third column.
It selects all rows of the first column, returning a 1D array.
arr[1:4] selects rows at indices 1, 2, and 3 (the stop index is exclusive).
Broadcasting is NumPy's ability to perform element-wise operations on arrays of different shapes by automatically expanding the smaller array to match dimensions.
arr * 3 multiplies every element of arr by 3 without an explicit loop — the scalar is broadcast across the array.
arr.reshape(3, 4) returns a 3×4 view of the array (total elements must match).
It flattens a multi-dimensional array into a 1D array, returning a view when possible.
Flashcards
Flip to reveal
Focus Mode
Spaced repetition
Multiple Choice
Test your knowledge
Type Answer
Active recall
Learn Mode
Multi-round mastery
Match Game
Memory challenge