Advertisements
Advertisements
प्रश्न
Using the arrays created in Question 4 above, write NumPy commands for the following:
- Find the transpose of ones and myarray2.
- Sort the array vowels in reverse.
- Sort the array myarray1 such that it brings the lowest value of the column in the first row and so on.
कोड लेखन
Advertisements
उत्तर
a)
ones_transpose = ones.transpose()
myarray2_transpose = myarray2.transpose()
print("Transpose of ones:\n", ones_transpose)
print("Transpose of myarray2:\n", myarray2_transpose)
Output:
Traspose of ones:
[[1 |
1] |
[1 |
1] |
[1 |
1] |
[1 |
1] |
[1 |
1]] |
Transpose of myarray2
[[4. |
24. |
44.] |
[8. |
28. |
48.] |
[12. |
32. |
52.] |
[16 |
36. |
56.] |
[20. |
40. |
60.]] |
b)
vowels_reverse_sorted = np.sort(vowels)[::-1]
print("Reverse sorted vowels array:\n", vowels_reverse_sorted)
Output:
Reverse sorted vowels array:
['u' 'o' 'i' 'e' 'a']
c)
myarray1_sorted = np.sort(myarray1, axis=0)
print("Sorted myarray1:\n", myarray1_sorted)
Output:
| [[0. | -2 | -19] |
| [2.7 | 0. | 13.] |
| [10.6 | 3.4 | 99.9]] |
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
