(a) Key Features of NumPy
1 Fast Numerical Computation : NumPy is written in C and optimized for speed, making mathematical operations significantly faster than Python lists.
2 Multidimensional Arrays : It provides the ndarray object that supports 1D, 2D, and higher-dimensional arrays.
3 Vectorized Operations : Operations are applied on the whole array without loops — cleaner and faster.
4 Memory Efficient : NumPy arrays store elements of the same data type, reducing memory usage.
5 Large Collection of Mathematical Functions : Includes linear algebra, statistics, trigonometry, reshaping, sorting, and more.
6 Supports Broadcasting : Enables operations between arrays of different shapes.
Differences Between NumPy Arrays and Python Lists
| Feature | NumPy Array | Python List |
|---|---|---|
| Speed | Much faster (C optimized) | Slower |
| Data Type | Homogeneous (one type) | Heterogeneous (mixed types) |
| Memory Usage | Lower | Higher |
| Operations | Element-wise directly | Need loops for element-wise |
| Dimensions | Supports multi-dimensional | Mostly 1D (nested lists for 2D) |
| Functions | Large scientific function library | Limited built-in operations |
(b) Python program using NumPy to create one-dimensional and two-dimensional arrays and display their shape, dimensions, and data type
Author
Name : Rohit
Roll Number : 2501060098
Section : "A"
Program : BCA(AI & DS
Course : Problem Solving Python
Assignment : 04