Add alternative solution for Q.19

This commit is contained in:
Henry Ji 2022-10-10 20:58:25 +08:00 committed by GitHub
parent 4c45b35878
commit fccab23c7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -211,6 +211,12 @@ Z[1::2,::2] = 1
Z[::2,1::2] = 1 Z[::2,1::2] = 1
print(Z) print(Z)
# Alternative solution: Using reshaping
arr = np.ones(64,dtype=int)
arr[::2]=0
arr = arr.reshape((8,8))
print(arr)
< q20 < q20
Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆) Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)