Assignment: NumPy Basics 1. What is NumPy?
NumPy (Numerical Python) is a Python library used
for numerical and scientific computing. It provides support for large multi-dimensional arrays and
matrices and includes a large collection of mathematical functions to operate on these arrays efficiently.
Why should we use NumPy? • It is faster than regular Python lists due to optimized C-based
operations. • It supports multi-dimensional arrays for scientific and machine-learning tasks. • It provides
vectorized operations which reduce the need for loops. • It integrates well with data science and
machine-learning libraries. 2. Steps to create a 2D array Example: from numpy import array arr2d =
array([[1, 2, 3], [4, 5, 6]]) Output: [[1 2 3] [4 5 6]] 3. Steps to create a 3D array Example: from numpy
import array arr3d = array([ [[1, 2], [3, 4]], [[5, 6], [7, 8]] ]) Output: [ [[1 2] [3 4]] [[5 6] [7 8]] ]