mardi 22 septembre 2020

how can I correct a 2D array in python

#set up an array

np.random.seed(1)
Z=np.random.uniform(0,10,size=(5,8))
Z=np.around(Z,2)

#print result

print(Z)

result

[[4.17 7.2  0.   3.02 1.47 0.92 1.86 3.46]
 [3.97 5.39 4.19 6.85 2.04 8.78 0.27 6.7 ]
 [4.17 5.59 1.4  1.98 8.01 9.68 3.13 6.92]
 [8.76 8.95 0.85 0.39 1.7  8.78 0.98 4.21]
 [9.58 5.33 6.92 3.16 6.87 8.35 0.18 7.5 ]]

I am supposed to use a single cell to print the 3rd row and 6th column of Z.

for example Row 3: xxx Column 6: xxxx

Z[2, 5]

result

9.68

I know I got the right answer but I am not sure how to set up in the example above, any ideas?




Aucun commentaire:

Enregistrer un commentaire