Lifè of a coder... be likee...:
.
.
nevermind answer this:
write a numpy program to create a 8x8 matrix and fill it with a checkboard pattern:
[[0 1 0 1 0 1 0 1]
[0 1 0 1 0 1 0 1]
[0 1 0 1 0 1 0 1]
[0 1 0 1 0 1 0 1]
[0 1 0 1 0 1 0 1]
[0 1 0 1 0 1 0 1]
[0 1 0 1 0 1 0 1]
[0 1 0 1 0 1 0 1]]
Attachments:
![](https://hi-static.z-dn.net/files/d54/0f0568c54b4d44b9c7c17eda12e40637.jpg)
Answers
Answered by
4
Answer:
import numpy as np
x = np.ones((3,3))
print("Checkerboard pattern:")
x = np.zeros((8,8),dtype=int)
x[1::2,::2] = 1
x[::2,1::2] = 1
print(x)
Answered by
4
import numpy as np
x = np.ones((3,3))
print("Checkerboard pattern:")
x = np.zeros((8,8),dtype=int)
x[1::2,::2] = 1
x[::2,1::2] = 1
print(x)
Similar questions