Question: Array Attributes 1. Create a 4 x 4 NumPy array B1 filled with 1's of type int. 2. Print the contents of B1. 3. Print
Array Attributes
1. Create a 4 x 4 NumPy array B1 filled with 1's of type int.
2. Print the contents of B1.
3. Print the number of dimensions of B1.
4. Print the size of each dimension of B1.
5. Print the total size of B1.
6. Print the data type of B1.
7. Print the size (in bytes) of each array element of B1.
8. Print the total size (in bytes) of B1.
Array Indexing
9. Create a NumPy array B2 using arange with values 1 - 12 (inclusive).
10. Print the first 4 values of B2.
11. Print the next 4 values of B2.
12. Print the last 4 values of B2.
13. Print the every other element of B1.
14. Print the elements in reverse order of B1.
Array Slicing
15. Creat a 3 x 3NumPy array B3 using full with the value set to 8.
16. Change the following elements in B3: 1st element in row1 = 0, the 2nd element in row2 = 1, and the 3rd ROW = 2.
17. Print the contents of B3.
18. Print the 2nd row of B3.
19. Print the 3rd column of B3.
20. Print the central element in the 3 x 3 array
Array Reshaping
21. Creat a NumPy array B4 using arange with values 1 - 16 (inclusive) and reshape it into a 4 x 4 grid.
22. Print the contents of B4.
23. Creat a NumPy array B5 using arange with values 5 - 50 (inclusive) with step size of 5 and reshape it into a 5 x 2 grid.
24. Print the contents of B5.
Array Concatenation and Splitting
25. Creat a NumPy array B6 using arange with values 1 - 4 (inclusive).
26. Creat a NumPy array B7 using arange with values 4 - 1 (inclusive).
27. Creat array B8 by concatenating arrays B6 and B7.
28. Print the contents of B8.
29. Creat array B9 using vertical stacking to concatenate arrays B6 and B7.
30. Print the contents of B9.
31. Reshape array B9 into a 4 x 2 grid
32. Print the new array B9.
33. Creat array B10 using horizonal stacking to concatenate arrays B9 with itself (B9).
34. Print the contents of B10.
35. Creat a NumPy array B11 with 9 elements containing the first nine counting numbers (1-9). [Use np.arrange]
36. Print array B11
37. Creat a NumPy array B12 by splitting array B11 so that there are 3 elements in each subarray.
38. Print array B12
39. Set array B13 to be the first subarray of B12.
40. Print array B13
41. Set array B14 to be the second subarray of B12.
42. Print array B14
43. Set array B15 to be the third subarray of B12.
44. Print array B15
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
