Inheritance: Logic 
Gates and Circuits 
By: Giovannie Sanchez 
Kevin Flores
Important to know… 
• Inheritance - is the ability for one class to be 
related to another class. 
• The structure relationship is called inheritance 
hierarchy. 
• Lists, tuples, and strings are all types of 
sequential collections. 
• They all inherit common data and 
organization and operands 
Super 
Class 
•Logic Gate 
•Everyone Inherits the class. 
Class 
One 
•Binary Gate 
•Unary Gate 
Class 
Two 
•And Gate 
•Or Gate 
•Not Gate
What is Heriarchy? & 
What are we using? 
Heriarchy is used to simplify and to 
understand the relationship between 
inheritable classes. 
Its more organized.
The operands and, or… 
• And – has two inputs, and one output which 
can be either 0 (false) or 1(true). 
• Or – has two inputs and its output is either 
true (1) if a veritable solution is present out of 
the two inputs or its completely false. 
Or 
Gate 
Binary 
Gate 
Logic 
Gate 
• Method 
• Parameter 
And 
Gate 
Binary 
Gate • Method 
• Method 
• Parameter 
• Parameter 
Logic 
Gate
The operand or… 
• Not – has a single input and the output is 
always the opposite of the input. 
• Method 
• Parameter 
Not 
Gate 
Unary 
Gate • Method 
• Method 
• Parameter 
• Parameter 
Logic 
Gate
The Circuit… 
The output lines from the two AND gates feed directly 
into the OR gate, and the resulting output from the OR 
gate is given to the NOT gate. If we apply a set of input 
values to the four input lines (two for each AND gate), 
the values are processed and a result appears at the 
output of the NOT gate.
Let’s get started… 
LogicGate 
• At the top of the hierarchy, the 
LogicGate class represents the most 
general characteristics of logic 
gates: namely, a label for the gate 
and an output line. 
• The next level of subclasses breaks 
the logic gates into two families, 
those that have one input line and 
those that have two. Below that, the 
specific logic functions of each 
appear.
The Connectors…are… 
Connector Class 
• The Connector class will not reside 
in the gate hierarchy. 
• It will, however, use the gate 
hierarchy in that each connector will 
have two gates, one on either end. 
• This relationship is very important in 
object-oriented programming. It is 
called the HAS-A Relationship
Let’s look at the code… 
Source Code 
• 7 Classes 
• Each one inherit except the 
LogicGate and Connector 
Method Inherit 
Logic 
Gate 
3 NO 
Binary 
Gate 
4 YES 
Unary 
Gate 
3 YES 
And 
Gate 
2 YES 
Or 
Gate 
2 YES 
Not 
Gate 
2 YES 
Connector 3 NO

Python - Logic Gates

  • 1.
    Inheritance: Logic Gatesand Circuits By: Giovannie Sanchez Kevin Flores
  • 2.
    Important to know… • Inheritance - is the ability for one class to be related to another class. • The structure relationship is called inheritance hierarchy. • Lists, tuples, and strings are all types of sequential collections. • They all inherit common data and organization and operands Super Class •Logic Gate •Everyone Inherits the class. Class One •Binary Gate •Unary Gate Class Two •And Gate •Or Gate •Not Gate
  • 3.
    What is Heriarchy?& What are we using? Heriarchy is used to simplify and to understand the relationship between inheritable classes. Its more organized.
  • 4.
    The operands and,or… • And – has two inputs, and one output which can be either 0 (false) or 1(true). • Or – has two inputs and its output is either true (1) if a veritable solution is present out of the two inputs or its completely false. Or Gate Binary Gate Logic Gate • Method • Parameter And Gate Binary Gate • Method • Method • Parameter • Parameter Logic Gate
  • 5.
    The operand or… • Not – has a single input and the output is always the opposite of the input. • Method • Parameter Not Gate Unary Gate • Method • Method • Parameter • Parameter Logic Gate
  • 7.
    The Circuit… Theoutput lines from the two AND gates feed directly into the OR gate, and the resulting output from the OR gate is given to the NOT gate. If we apply a set of input values to the four input lines (two for each AND gate), the values are processed and a result appears at the output of the NOT gate.
  • 8.
    Let’s get started… LogicGate • At the top of the hierarchy, the LogicGate class represents the most general characteristics of logic gates: namely, a label for the gate and an output line. • The next level of subclasses breaks the logic gates into two families, those that have one input line and those that have two. Below that, the specific logic functions of each appear.
  • 9.
    The Connectors…are… ConnectorClass • The Connector class will not reside in the gate hierarchy. • It will, however, use the gate hierarchy in that each connector will have two gates, one on either end. • This relationship is very important in object-oriented programming. It is called the HAS-A Relationship
  • 10.
    Let’s look atthe code… Source Code • 7 Classes • Each one inherit except the LogicGate and Connector Method Inherit Logic Gate 3 NO Binary Gate 4 YES Unary Gate 3 YES And Gate 2 YES Or Gate 2 YES Not Gate 2 YES Connector 3 NO