Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fccab23

Browse files
authored
Add alternative solution for Q.19
1 parent 4c45b35 commit fccab23

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

source/exercises100.ktx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ Z[1::2,::2] = 1
211211
Z[::2,1::2] = 1
212212
print(Z)
213213

214+
# Alternative solution: Using reshaping
215+
arr = np.ones(64,dtype=int)
216+
arr[::2]=0
217+
arr = arr.reshape((8,8))
218+
print(arr)
219+
214220
< q20
215221
Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)
216222

0 commit comments

Comments
 (0)