NumPy Arrays

NumPy (Numerical Python) is the fundamental package for scientific computing in Python. It provides support for large, multi-dimensional arrays and matrices.

Why NumPy?

  • Speed: NumPy operations are much faster than standard Python lists.
  • Vectorization: Apply operations to entire arrays without loops.
  • Math: Built-in linear algebra functions.

Creating Arrays

python
Output:
Click "Run Code" to see output

Array Operations

Notice how we can multiply arrays directly without writing a loop. This is called broadcasting.

python
Output:
Click "Run Code" to see output