Numpy Exercis-2
Numpy Exercis-2
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.