Advertisements
Advertisements
Question
Create the following NumPy arrays:
Use nested Python lists to create a 2-D array called myarray1 having 3 rows and 3 columns and store the following data:
| 2.7, | -2, | -19 |
| 0, | 3.4, | 99.9 |
| 10.6, | 0, | 13 |
Code Writing
Advertisements
Solution
A 2-D NumPy array called myarray1 can be created using nested Python lists as follows:
import numpy as np
myarray1 = np.array
([
[2.7, -2, -19],
[0, 3.4, 99.9],
[10.6, 0, 13]
])
print(myarray1)
Output:
[[2.7. |
-2. |
-19.] |
[0. |
3.4. |
99.9] |
[10.6. |
0. |
|
shaalaa.com
Is there an error in this question or solution?
