Practical_6: Numpy#
Exercise 1:#
Create a NumPy array of integers from 1 to 10.
# Exercise 1
Exercise 2:#
Create a 3x3 NumPy array filled with zeros.
# Exercise 2
Exercise 3:#
Create a NumPy array of 10 evenly spaced numbers between 0 and 5.
# Exercise 3
Exercise 4:#
Create a 5x5 identity matrix using NumPy.
# Exercise 4
Exercise 5:#
Create a 4x4 matrix with random values between 0 and 1.
# Exercise 5
Exercise 6:#
Find the shape of a NumPy array.
# Exercise 6
Exercise 7:#
Reshape a 1D NumPy array of 16 elements into a 4x4 matrix.
# Exercise 7
Exercise 8:#
Find the data type of the elements in a NumPy array.
# Exercise 8
Exercise 9:#
Create a NumPy array of integers from 1 to 100 and find all even numbers in the array.
# Exercise 9
Exercise 10:#
Generate a 6x6 matrix of random integers between 10 and 50.
# Exercise 10
Exercise 11:#
Slice a 2D NumPy array to extract a submatrix.
# Exercise 11
Exercise 12:#
Calculate the sum of all elements in a NumPy array.
# Exercise 12
Exercise 13:#
Calculate the mean, median, and standard deviation of a NumPy array.
# Exercise 13
Exercise 14:#
Find the maximum and minimum values in a NumPy array.
# Exercise 14
Exercise 15:#
Create a NumPy array of 20 random integers and find the index of the maximum value.
# Exercise 15
Exercise 16:#
Create a NumPy array and reverse its elements.
# Exercise 16
Exercise 17:#
Create a 3x3 matrix and multiply it element-wise by another 3x3 matrix.
# Exercise 17
Exercise 18:#
Create a diagonal matrix from a given 1D array.
# Exercise 18
Exercise 19:#
Perform matrix multiplication on two 2D NumPy arrays.
# Exercise 19
Exercise 20:#
Flatten a 2D NumPy array into a 1D array.
# Exercise 20
Exercise 21:#
Stack two NumPy arrays vertically.
# Exercise 21
Exercise 22:#
Stack two NumPy arrays horizontally.
# Exercise 22
Exercise 23:#
Split a NumPy array into multiple sub-arrays.
# Exercise 23
Exercise 24:#
Generate a random NumPy array and round each element to two decimal places.
# Exercise 24
Exercise 25:#
Find the unique elements of a NumPy array.
# Exercise 25
Exercise 26:#
Replace all elements in a NumPy array that are less than a specific value with that value.
# Exercise 26
Exercise 27:#
Find the cumulative sum of the elements in a NumPy array.
# Exercise 27
Exercise 28:#
Create a NumPy array and find the number of non-zero elements in it.
# Exercise 28
Exercise 29:#
Create a NumPy array of random integers and sort it in ascending order.
# Exercise 29
Exercise 30:#
Find the row-wise and column-wise sum of a 3x3 matrix.
# Exercise 30
Exercise 31:#
Generate a 2D NumPy array with random values and normalize it (scale the values between 0 and 1).
# Exercise 31
Exercise 32:#
Create two NumPy arrays and find the dot product.
# Exercise 32
Exercise 33:#
Find the trace of a square NumPy matrix.
# Exercise 33
Exercise 34:#
Create a 2D array and swap two rows.
# Exercise 34
Exercise 35:#
Create a 1D NumPy array and convert it into a column vector.
# Exercise 35
Exercise 36:#
Find the determinant of a 3x3 matrix.
# Exercise 36
Exercise 37:#
Find the eigenvalues and eigenvectors of a 2x2 matrix.
# Exercise 37
Exercise 38:#
Solve a system of linear equations using NumPy.
# Exercise 38
Exercise 39:#
Add Gaussian noise to a NumPy array.
# Exercise 39
Exercise 40:#
Create a 4x4 matrix and extract the diagonal elements.
# Exercise 40
Exercise 41:#
Generate a NumPy array of 100 random values and clip the values to a range between 10 and 50.
# Exercise 41
Exercise 42:#
Create a 2D NumPy array and replace all negative values with zero.
# Exercise 42
Exercise 43:#
Find the inner and outer products of two NumPy arrays.
# Exercise 43
Exercise 44:#
Calculate the pairwise distances between points in a NumPy array.
# Exercise 44
Exercise 45:#
Create a structured NumPy array with fields for name
, age
, and height
.
# Exercise 45
Exercise 46:#
Create a 5x5 matrix of random integers and count the occurrences of each unique value.
# Exercise 46
Exercise 47:#
Generate a random 3x3 NumPy array and subtract the mean of each row from the corresponding row.
# Exercise 47
Exercise 48:#
Create a NumPy array of random integers and check if any of the values are greater than 50.
# Exercise 48
Exercise 49:#
Calculate the moving average of a 1D NumPy array.
# Exercise 49
Exercise 50:#
Find the Pearson correlation coefficient between two NumPy arrays.
# Exercise 50
Exercise 51:#
Convert a NumPy array of radians to degrees.
# Exercise 51
Exercise 52:#
Create a random NumPy array and compute its variance and standard deviation.
# Exercise 52
Exercise 53:#
Create a 2D NumPy array and find the indices of the maximum values along each axis.
# Exercise 53
Exercise 54:#
Compute the inverse of a 2x2 NumPy matrix.
# Exercise 54
Exercise 55:#
Create a NumPy array of 10 random values and standardize it (mean 0, variance 1).
# Exercise 55
Exercise 56:#
Perform element-wise addition and subtraction on two NumPy arrays.
# Exercise 56
Exercise 57:#
Create a NumPy array of random values and find the maximum element’s index.
# Exercise 57
Exercise 58:#
Create a 3x3 NumPy array and rotate it by 90 degrees.
# Exercise 58
Exercise 59:#
Compute the Frobenius norm of a matrix.
# Exercise 59
Exercise 60:#
Create a 3D NumPy array and slice out a subarray.
# Exercise 60