w3resource

NumPy: Advanced Exercises, Practice, Solution

Advanced NumPy Exercises [ 33 exercises with solution]

[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]

1. Write a NumPy program to find the dot product of two arrays of different dimensions.
Click me to see the sample solution

2. Write a NumPy program to create a 3x3 identity matrix and stack it vertically and horizontally.
Click me to see the sample solution

3. Write a NumPy program to create a 4x4 array with random values and find the sum of each row.
Click me to see the sample solution

4. Write a NumPy program to create a 3x3 array with random values and subtract the mean of each row from each element.
Click me to see the sample solution

5. Write a NumPy program to create a 3x3 array with random values and subtract the mean of each column from each element.
Click me to see the sample solution

6. Write a NumPy program to create a 5x5 array with random values and normalize it row-wise.
Click me to see the sample solution

7. Write a NumPy program to create a 5x5 array with random values and normalize it column-wise.
Click me to see the sample solution

8. Write a NumPy program to create a 3x3x3 array with random values and find the sum along the last axis.
Click me to see the sample solution

9. Write a NumPy program to create a 5x5 array with random values and sort each row.
Click me to see the sample solution

10. Write a NumPy program to create a 5x5 array with random values and sort each column.
Click me to see the sample solution

11. Write a NumPy program to create a 5x5 array with random values and find the second-largest value in each row.
Click me to see the sample solution

12. Write a NumPy program to create a 5x5 array with random values and find the second-largest value in each column.
Click me to see the sample solution

13. Write a NumPy program to create a 5x5 array with random values and replace the maximum value with 0.
Click me to see the sample solution

14. Write a NumPy program to create a 5x5 array with random values and replace the minimum value with 0.
Click me to see the sample solution

15. Write a NumPy program to create a 5x5 array with random values and calculate the exponential of each element.
Click me to see the sample solution

16. Write a NumPy program to create a 4x4 array with random values and compute the eigenvalues and eigenvectors.
Click me to see the sample solution

17. Write a NumPy program to create a 6x6 array with random values and compute the inverse of the matrix.
Click me to see the sample solution

18. Write a NumPy program to create a 4x4 array with random values and calculate the determinant.
Click me to see the sample solution

19. Write a NumPy program to create a 3x3x3 array with random values and flatten it to a 1D array.
Click me to see the sample solution

20. Write a NumPy program to create a 5x5 array with random values and calculate the trace of the matrix.
Click me to see the sample solution

21. Write a NumPy program to create a 4x4 array with random values and extract the upper triangular part of the matrix.
Click me to see the sample solution

22. Write a NumPy program to create a 4x4 array with random values and extract the lower triangular part of the matrix.
Click me to see the sample solution

23. Write a NumPy program to create a 6x6 array with random values and compute the rank of the matrix.
Click me to see the sample solution

24. Write a NumPy program to create a 3x3 array with random values and compute the Frobenius norm of the matrix.
Click me to see the sample solution

25. Write a NumPy program to create a 5x5 array with random values and find the index of the maximum value in each row.
Click me to see the sample solution

26. Write a NumPy program to create a 5x5 array with random values and find the index of the minimum value in each row.
Click me to see the sample solution

27. Write a NumPy program to create a 3x3 array with random values and compute the QR decomposition.
Click me to see the sample solution

28. Write a NumPy program to create a 3x3 array with random values and compute the Cholesky decomposition.
Click me to see the sample solution

29. Write a NumPy program to create a 4x4 array with random values and swap the first and last rows.
Click me to see the sample solution

30. Write a NumPy program to create a 4x4 array with random values and rotate the array 90 degrees counterclockwise.
Click me to see the sample solution

31. Write a NumPy program to create a 4x4 array with random values and shift all elements one position to the right.
Click me to see the sample solution

32. Write a NumPy program to create a 4x4 array with random values and shift all elements one position downwards.
Click me to see the sample solution

33. Write a NumPy program to create a 3x3 array with random values and calculate the pairwise Euclidean distance between each pair of rows.
Click me to see the sample solution

Python-Numpy Code Editor:

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.

Test your Python skills with w3resource's quiz



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://198.211.115.131/python-exercises/numpy/index-advance.php