Lab 3
Download the ipynb
file numpy-I.ipynb.
NumPy Basics
Create a NumPy 1D array or vector with only even numbers between 12 to 124.
Print the shape, length, and data type of the array created in Ex 1.
Create a NumPy 1D array or vector with only odd numbers between 12 to 124 in decreasing order.
Modify the array create in Ex 1 so that its 15th element becomes 6103.
Create a 2\times5 matrix filled with numbers between 102 and 129 that are divisible by 3.
Create a NumPy array A
of shape (3, 4, 4)
such that each of the slices along the first axis (axis=0
) is an identity matrix.
Create a NumPy array A
of shape (3, 3, 5)
such that the last axis (column) of each of the slices along the first axis is [6101, 6102, 6103]
.
Check if a given matrix is symmetric.
Check if a given matrix is skew-symmetric.
Check if a given matrix is diagonal.
Check if a matrix is orthogonal.
Create a 6\times6 matrix with values 1, 2, 3, 4, 5 just above the diagonal and -3 everywhere else.