🔢

NumPy Essentials

77 cards · 🇺🇸 English

Array creation, indexing, broadcasting, and core NumPy operations.

Study all 77 cards for free

Flashcards, quizzes, pixel-art games and a daily review that remembers for you.

Study this deck free

Try the first 10 cards

1 / 10
Question

NumPy

Knew itLearning

Tap the card for the answer · swipe right if you knew it, left if not

Already have an account? Sign in

Cards

  1. 1NumPy
    A library for Python that adds support for large, multi-dimensional arrays and matrices with high-level mathematical functions
  2. 2NumPy import convention
    import numpy as np
  3. 3Ndarray
    NumPy's n-dimensional array data structure - a homogeneously typed array
  4. 4Homogeneously typed
    All elements of a NumPy array must be of the same type
  5. 5Create a 1D NumPy array
    np.array([1, 2, 3, 4])
  6. 6Create a 2D NumPy array
    np.array([[1, 2], [3, 4]])
  7. 7a list vs a NumPy array
    NumPy arrays are homogeneous, fixed-size, and optimized for numerical operations; lists are heterogeneous and dynamic
  8. 8Np.zeros()
    Creates an array filled with zeros of a specified shape
  9. 9Np.ones()
    Creates an array filled with ones of a specified shape
  10. 10Np.arange()
    Creates an array with evenly spaced values within a given interval (like Python's range)
  11. 11Np.linspace()
    Creates an array with a specified number of evenly spaced values between start and end
  12. 12np.arange() vs np.linspace()
    arange uses step size; linspace specifies number of points
  13. 13Array.shape
    A tuple representing the dimensions of the array
  14. 14Array.size
    The total number of elements in the array
  15. 15Array.ndim
    The number of dimensions (axes) of the array
  16. 16Array.dtype
    The data type of the array elements
  17. 17Change the shape of an array
    Use np.reshape() or array.reshape()
  18. 18Array.flatten()
    Returns a 1D copy of the array
  19. 19Array.ravel()
    Returns a flattened array (may return a view, not always a copy)
  20. 20Vectorization in NumPy
    Performing operations on entire arrays without explicit loops (much faster than Python loops)
  21. 21Can you add two NumPy arrays?
    Yes, element-wise: a + b
  22. 22What happens when you multiply two NumPy arrays?
    Element-wise multiplication (not matrix multiplication)
  23. 23Perform matrix multiplication
    Use np.dot(a, b) or a @ b (Python 3.5+)
  24. 24Universal functions (ufuncs)
    Functions that operate element-wise on arrays (e.g., np.sin, np.exp, np.sqrt)
  25. 25Np.sin()
    Computes the sine of each element in the array
  26. 26Np.exp()
    Computes e^x for each element in the array
  27. 27Np.sqrt()
    Computes the square root of each element in the array
  28. 28Np.sum()
    Returns the sum of all elements (or along a specified axis)
  29. 29Np.mean()
    Returns the arithmetic mean (average)
  30. 30Np.std()
    Returns the standard deviation

And 47 more cards. Study the whole deck free

Articles about this deck

More Programming decks

See all
Study all 77 cards free