Lesson 37 of 55 · Python
Introduction to NumPy
Duration: 20 minutes
Lesson 37 of 55 · Python
Duration: 20 minutes
python\nimport numpy as np\n\na = np.array([1, 2, 3])\nprint('Array:', a)\nprint('Mean:', a.mean())\n\n# 2‑D array (matrix)\nb = np.arange(6).reshape(2, 3)\nprint('2×3 matrix:\n', b)\n\n\nOperations on NumPy arrays are vectorized, meaning they execute C‑level loops under the hood—much faster than native Python loops.\n