title: How to randomly get 0 or 1 every time?
body: <p><strong>Display matrix of 0s and 1s</strong></p>
  <blockquote>
  <p>Write a function that displays an n-by-n matrix using the following
  header:</p>
  <pre><code>def printMatrix(n):
  </code></pre>
  <p>Each element is <code>0</code> or <code>1</code>, which is generated randomly. Write a test
  program that prompts the user to enter n and displays an <code>n</code>-by-<code>n</code>
  matrix. Here is a sample run:</p>
  <pre><code>Enter n: 3 
  010 
  000 
  111
  </code></pre>
  </blockquote>
  <p>Here is my idea:</p>
  <pre><code>from __future__ import print_function
  
  from random import randint, choice
  
  import random
  
  n = input (&quot;Enter an interger number:&quot;)
  k = randint(0, 1)
  for i in range (1, n+1):
      for j in range (1, n+1):
          print (format((i*j)/(i*j)*k, &quot;3d&quot;) , end = '')
      print ()
  </code></pre>