Python NumPy - Practice Exercises, Questions and Solutions
Example Questions on NumPy Array
- Create an empty and full NumPy array
- Create a Numpy array filled with all zeros
- Create a Numpy array filled with all ones
- Check whether a Numpy array contains a specified row
- Remove rows in Numpy array that contains non-numeric values
- Remove single-dimensional entries from shape of an array
- Find number of occurrences of a sequence
- Find most frequent value
- Combining a one and a two-dimensional
- Build an array of all combinations of two NumPy arrays
- Add a border around a NumPy array
- Compare two NumPy arrays
- Check whether specified values are present in NumPy array
- Get 2D diagonals of a 3D array
- Flatten a Matrix
- Flatten a 2d array into 1d array
- Move axes of an array to new positions
- Interchange two axes of an array
- Fibonacci Series using Binet Formula
- Counts number of non-zero values
- Count number of elements along a given axis
- Trim leading and/or trailing zeros from a 1-D array
- Change data type of given numpy array
- Reverse a numpy array
- Make a NumPy array read-only
Coding Problems
- Sum of All Elements in a Numpy Array
- Maximum Element in a Numpy Array
- Mean of a Numpy Array
- Reshape a Numpy Array
- Standard Deviation
- Element-wise Exponentiation
- Array Concatenation
- Reverse Rows of a 2D Array
- Diagonal Elements in an Array
- 3D Array from a List of Lists
- Accessing Element in a 3D Array
- Maximum Element along Each Axses in a 3D Array
- Slice a 3D Array
- Flatten a 3D Array
Example Questions on NumPy Matrix
- Maximum value from given matrix
- Minimum value from given matrix
- Find number of rows and columns of a given matrix
- Select elements from a given matrix
- Find sum of values in a matrix
- Calculate sum of the diagonal elements
- Adding and Subtracting Matrices
- Ways to add row/columns
- Matrix Multiplication
- Get eigen values of a matrix
- Calculate determinant of a matrix
- Inverse a matrix using NumPy
- Count frequency of unique values
- Multiply matrices of complex numbers
- Outer product of two given vectors
- Calculate inner, outer and cross products of matrices and vectors
- Compute covariance matrix of two given
- Convert covariance matrix to correlation matrix
- Compute Kronecker product of two mulitdimension
- Convert matrix into a list
Coding Problems
Example Questions on NumPy Indexing
- Replace array elements that doesnât satisfy given condition
- Return indices of elements where given condition is satisfied
- Replace NaN values with average of columns
- Replace negative value with zero
- Get values of an NumPy array at certain index positions
- Find indices of elements equal to zero
- Remove columns in array that contains non-numeric values
- Access different rows of a multidimensional
- Get row numbers of array having element larger than X
- Get filled diagonals of array
- Check elements present in an array
- Combined array index by index
Example Questions on NumPy Linear Algebra
- Find a matrix or vector norm
- Calculate QR decomposition of a given matrix
- Compute condition number of a given matrix
- Compute eigenvalues and right eigenvectors of a given square array
- Calculate Euclidean distance
Coding Problem
Example Questions on NumPy Random
- Create a Numpy array with random values
- Choose elements from the list with different probability
- Get weighted random choice
- Generate Random Numbers From Uniform Distribution
- Get Random Elements from geometric distribution
- Get Random elements from Laplace distribution
- Return a Matrix of random values from a uniform distribution
- Return a Matrix of random values from a Gaussian distribution
Questions on NumPy Sorting and Searching
- Get indices of sorted array
- Finding k smallest values
- Get n-largest values of an array
- Sort values in a matrix
- Filter out integers from float numpy array
- Find indices into a sorted array
Coding Problems
Questions on NumPy Mathematics
- Get element-wise true division of an array
- Calculate element-wise absolute value of an array
- Compute negative of the NumPy array
- Multiply 2d numpy array corresponding to 1d array
- Computes inner product of two arrays
- Compute nth percentile of the NumPy array
- Calculate n-th order discrete difference along given axis
- Calculate sum of all columns in a 2D NumPy array
- Calculate average values of two given NumPy arrays
- Compute numerical negative value for all elements in an array
- Get floor, ceiling and truncated values of the elements of an array
- Round elements of NumPy array to nearest integer
- Find round off the values of given matrix
- Determine positive square-root of an array
- Evaluate Einsteinâs summation convention of two multidimensional NumPy arrays
Questions on NumPy Statistics
- Compute median of the flattened NumPy array
- Find Mean of a List of Numpy Array
- Calculate mean of array ignoring NaN value
- Get mean value from given matrix
- Compute variance of NumPy array
- Compute standard deviation of NumPy array
- Compute pearson product-moment correlation coefficients of two given arrays
- Calculate mean across dimension in a 2D NumPy array
- Calculate average, variance and standard deviation in Python
- Describe a NumPy Array
Questions on Polynomial
- Define a polynomial function
- Add one polynomial to another
- Subtract one polynomial to another
- Multiply a polynomial to another
- Divide a polynomial to another
- Find roots of the polynomials
- Evaluate a 2-D polynomial series on Cartesian product
- Evaluate a 3-D polynomial series on Cartesian product
Questions on NumPy Strings
- Repeat all elements of a NumPy array of strings
- Split element of a given NumPy array with spaces
- Insert a space between characters of all the elements
- Find length of each string element in the Numpy array
- Swap case of an array of string
- Change case to uppercase of elements
- Change case to lowercase of elements
- Join String by a separator
- Check if two same shaped string arrayss one by one
- Count number of substrings in an array
- Find lowest index of the substring in an array
- Get boolean array when values end with a particular character
More Questions on NumPy
- Different ways to convert a dictionary to a NumPy array
- Convert a list and tuple into NumPy arrays
- Ways to convert array of strings to array of floats
- Convert a NumPy array into a csv file
- Convert an image to NumPy array and save it to CSV file
- Save a NumPy array to a text file
- Load data from a text file
- Plot line graph from NumPy array
- Create Histogram using NumPy