title: OOP in Python , Getting Truth Table using Tree model
body: <p>So I am given a task to use OOP to get the following truth table. I have to make method make_tt() on an expression i.e.</p>
  <pre><code>e=Eq(NOT(Var('y')),Var('x')) 
  </code></pre>
  <p>such that it returns the following truth table.</p>
  <p>where, Eq represent '==' and NOT represent '!'</p>
  <pre><code>   y | x    | !y==x
  True | True | False
  False| True | True
  True | False| True
  False| False| False
  </code></pre>
  <p>I have first made parent class Expr from which I will make Eq and Not class to inherit common things but I don't know how to write make_tt() such that it produces the following results.</p>
  <pre><code>class Expr:
    def __init__ (self,left,right):
      self.left=left
      self.right=right
  
    def __str__(self):
      return f'{self.left}{self.sign}{self.right}'
  
  class Not(Expr):
    def __init__(self,variable):
      self.variable=variable
  
    sign='!'
  
    def __str__(self):
      return f'{self.sign}{self.variable}'
  
  class Eq(Expr):
    sign='=='
  
  class Var:
    def __init__(self,value):
      self.value=value
  
    def __str__(self):
      return str(self.value)
  
  e=Eq(NOT(Var('y')),Var('x'))
  </code></pre>
  <p>if i do this</p>
  <pre><code>e.make_tt()
  </code></pre>
  <p>It should produce the truth table as you have seen above.</p>
  <pre><code>   y | x    | !y==x
  True | True | False
  False| True | True
  True | False| True
  False| False| False
  </code></pre>