Sie sind auf Seite 1von 3

Patanjali Rishikul

Topic: Numpy

1. What Is Numpy?
2. What Is A Numpy Array?
3. What Advantages Do Numpy Arrays Offer Over Python Lists?
4. Explain numpy.hsplit(array, 3).
5. Explain with an example difference between 1D and 2D arrays.
6. Write a NumPy program to print the NumPy version in your system.
7. Reverse the array, a=[1 2 3 4 -8 -10] to floating values [-10. -8. 4. 3. 2. 1.]
8. Write a NumPy program to convert a list of numeric value into a one-dimensional
NumPy array.
9. Write a NumPy program to create a 3x3 matrix with values ranging from 2 to 10.
10. Write a NumPy program to create a null array of size 10 and update sixth value to 11.
11. Write a NumPy program to an array converted to a float type.[1,2,3,4] to [1.,2.,3.,4.,]
12. Explain linear regression, covariance and coherence with example.
13. Name any two arithmetic operations that can be performed on numpy array.
14. Explain arrange() function with an example.
15. Explain linspace(), fromiter(), zeros(), ones() and empty() functions.
16. Explain array slicing with a suitable example.
17. What will be the output of np.vsplit(ary,2)
ary=([[1 2 3 4 5],[11 12 13 14 15], [21 22 23 24 25],
[31 32 33 34 35]])
18. What will be the output of np.arange(25.0).reshape(5,5).
19. Ar1=[[3 4 5], Ar2==[[6 1], [6 8 ], [2 1]]
[6 8 8]
[2 1 3]]
What will be the output of concatenate((Ar1, Ar2) axis=1)
20. Write a NumPy program to create a 2d array with 1 on the border and 0 inside.
[[ 1. 1. 1. 1. 1.]
[ 1. 0. 0. 0. 1.]
[ 1. 0. 0. 0. 1.]
[ 1. 0. 0. 0. 1.]
[ 1. 1. 1. 1. 1.]]
21. Write a NumPy program to create a 8x8 matrix and fill it with a checkerboard pattern.
[[0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0]
[0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0]
[0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0]
[0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0]]
22. Write a NumPy program to append values to the end of an array.
Original array:
[10, 20, 30]
After append values to the end of the array:
[10 20 30 40 50 60 70 80 90]

23. Write a NumPy program to convert the values of Centigrade degrees into
Fahrenheit degrees. Centigrade values are stored into a NumPy array
Sample Array [0, 12, 45.21 ,34, 99.91]
Expected Output:
Values in Fahrenheit degrees:
[ 0. 12. 45.21 34. 99.91]

24. Write a NumPy program to find the unique values of two arrays. Array1: [ 0
10 20 40 60 80]
Array2: [10, 30, 40, 50, 70]
Unique values that are in only one (not both) of the input arrays:
[ 0 20 30 50 60 70 80]
25. Write a NumPy program to create a new array of 3*5, filled with 2.
26. Write a NumPy program to split of an array of shape 4x4 it into two arrays along
the second axis.
Sample array :
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]
[12 13 14 15]]
Expected Output:
[array([[ 0, 1],
[ 4, 5],
[ 8, 9],
[12, 13]]), array([[ 2, 3],
[ 6, 7],
[10, 11],
[14, 15]]), array([], shape=(4, 0), dtype=int64)]
27. Write a NumPy program to sum of all the multiples of 3 or 5 below 100.
Array:
[ 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54
55 57 60 63 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99]
Ans. 2318
28. Explain hsplit() and vsplit() with suitable example.
29. Exaplin concatenate(), vstack() and hstack().
30. Write a NumPy program to create an array of (3, 4) shape, multiply every
element value by 3 and display the new array. Original array elements:
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
New array elements:
[[ 0 3 6 9]
[12 15 18 21]
[24 27 30 33]]

Das könnte Ihnen auch gefallen