0% found this document useful (0 votes)
3 views

Numpy Exercis-2

The document outlines a series of NumPy exercises categorized into easy, medium, and hard levels, ranging from basic operations like addition and subtraction to more complex tasks like dot products and correlation coefficients. Each exercise provides specific instructions on creating and manipulating NumPy arrays to perform various mathematical operations. The exercises aim to enhance understanding and proficiency in using NumPy for numerical computations.

Uploaded by

Sami Sanadi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Numpy Exercis-2

The document outlines a series of NumPy exercises categorized into easy, medium, and hard levels, ranging from basic operations like addition and subtraction to more complex tasks like dot products and correlation coefficients. Each exercise provides specific instructions on creating and manipulating NumPy arrays to perform various mathematical operations. The exercises aim to enhance understanding and proficiency in using NumPy for numerical computations.

Uploaded by

Sami Sanadi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Numpy Exercise

Easy Level (1-10)

1. Addition
Create two NumPy arrays of size 5 and add them element-wise.
2. Subtraction
Create two NumPy arrays of size 4 and subtract the second array from the
first.
3. Multiplication
Create a NumPy array of size 6 filled with numbers from 1 to 6. Multiply each
element by 2.
4. Division
Create an array of size 5 filled with numbers from 10 to 50 with a step of 10.
Divide each element by 2.
5. Exponential
Compute the exponential of an array [1, 2, 3, 4, 5] using NumPy.
6. Square Root
Compute the square root of an array [4, 9, 16, 25, 36].
7. Trigonometric Functions
Given an array angles = [0, 30, 45, 60, 90], compute the sine and cosine values.
(Convert degrees to radians before applying sin and cos)
8. Logarithm
Compute the natural log of an array [1, e, e^2, e^3].
9. Comparison Operations
Given an array a = [5, 10, 15, 20, 25], check which elements are greater than or
equal to 15.
10. Shallow Copy
Create an array and use .view() to create a shallow copy. Modify the copy and
observe if the original array is affected.

Medium Level (11-17)

11. Deep Copy


Create a NumPy array and use .copy() to make a deep copy. Modify the copy
and verify if the original array remains unchanged.
12. Dot Product
Compute the dot product of two arrays:

A = [[1, 2], [3, 4]]

B = [[5, 6], [7, 8]]

13. Aggregate Functions - Sum


Given a 3x3 matrix, compute the sum of all elements.
14. Aggregate Functions - Min & Max
Given an array arr = [12, 3, 45, 23, 19, 8], find the minimum and maximum values.
15. Aggregate Functions - Mean & Median
Compute the mean and median of an array [2, 5, 9, 12, 15, 20].
16. Standard Deviation
Find the standard deviation of an array [3, 7, 11, 15, 19].
17. Correlation Coefficient
Given two arrays x = [1, 2, 3, 4, 5] and y = [2, 4, 6, 8, 10], compute the correlation
coefficient.

Hard Level (18-20)

18. Element-wise Operations on Large Arrays


Generate two random NumPy arrays of size 1000 and perform element-wise
addition, subtraction, multiplication, and division.
19. Matrix Operations - Dot Product and Aggregates
Given two matrices of shape (3x3), compute their dot product and find the
maximum value in the resulting matrix.
20. Comparing Arrays and Logical Operations
Given two arrays a = [2, 4, 6, 8, 10] and b = [1, 3, 5, 7, 9], perform the following
operations:
o Check where a > b.
o Check where a == b.
o Compute a % 2 == 0 (check even numbers).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy