title: How to create 2D array from a function output
body: <p>The following function creates a 3 bit adder truth table. How can I get an 2D array structure from the output?</p>
  <pre><code>import numpy as np
  def truthTable(inputs=3):
      if inputs == 3:
          print(&quot;  A B C S Cout &quot;)
          for a in range(0, 2):
              for b in range(0, 2):
                  for c in range(0, 2):
                          cout = eval(&quot;((a &amp; b) | (a &amp; c) | (b &amp; c))&quot;)
                          s = eval(&quot;(a ^ b ^ c)&quot;)
                          print(str(a) + &quot;,&quot; + str(b) + &quot;,&quot; + str(c) + &quot;,&quot; + str(s) + &quot;,&quot; + str(cout))
  
  truthTable()
  </code></pre>
  <p>couurent o/p:</p>
  <pre><code>0,0,0,0,0
  0,0,1,1,0
  0,1,0,1,0
  0,1,1,0,1
  1,0,0,1,0
  1,0,1,0,1
  1,1,0,0,1
  1,1,1,1,1
  </code></pre>