title: n*n matrix of 0s and 1s in python
body: <p>How to create an <code>‘n*n’</code> checkerboard matrix with the values alternate <code>0 and 1</code>, using the <code>tile function</code>.</p>
  <p>For example:
  when n has a value of 2, Output should be:</p>
  <pre><code>[[0 1] 
   [1 0]]
  </code></pre>
  <p>I am able to create a <code>matrix with 0 and 1</code>, but they are not appearing alternatively, below is what i tried:</p>
  <pre><code>import numpy as np
  n = 4
  arr = ([0,1])
  print(np.tile(arr,(n,n//2)))
  </code></pre>
  <p>output I got:</p>
  <pre><code>[[0 1 0 1]
   [0 1 0 1]
   [0 1 0 1]
   [0 1 0 1]]`
  </code></pre>
  <p>output I want:</p>
  <pre><code>[[0 1 0 1]
   [1 0 1 0]
   [0 1 0 1]
   [1 0 1 0]]`
  </code></pre>