Python: Logic Gates Damian Gordon.

Slides:



Advertisements
Similar presentations
Logic Gates.
Advertisements

Computer Systems – Logic Gates Introduce the basic logic gates Introduce truth tables Introduce Boolean algebra (dont panic!) Examples of combining gates.
Def f(n): if (n == 0): return else: print(“*”) return f(n-1) f(3)
Basic Logical Operations (fascinating)
Lecture. Outline Bits Gates Combinatorial Logic Spice Hands-On Stuff.
Universal Gates Sum of Products Products of Sum
Digital Electronics Dan Simon Cleveland State University ESC 120 Revised December 30, 2010.
James Tam Basic Logical Operations (Fascinating) In this section you will learn what are the basic logical operations and how to evaluate different logical.
James Tam AND OR NOT NAND NOR XOR Basic logic operations (fascinating)
Lab 1 Structure of a PLD Module M1.4 Experiment 1 (p. 40)
Generalized De Morgan’s Theorem Lecture L5.4 Section 5.1.
Functional Notation Addendum to Chapter 4. 2 Logic Notation Systems We have seen three different, but equally powerful, notational systems for describing.
Simple One and Two Input Logic Gates Truth Tables and Function Tables Based Upon TTL Levels.
Chapter 9 IF Statement Bernard Chen. If Statement The main statement used for selecting from alternative actions based on test results It’s the primary.
LOGIC GATES Logic generally has only 2 states, ON or OFF, represented by 1 or 0. Logic gates react to inputs in certain ways. Symbol for AND gate INPUT.
XOR and XNOR Logic Gates. XOR Function Output Y is TRUE if input A OR input B are TRUE Exclusively, else it is FALSE. Logic Symbol  Description  Truth.
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Elementary Digital Logic Apps O/S Arch  Arch Logic Digital Analog.
NOCTI Review Lesson 4 Objectives:
Python: Modularisation Damian Gordon. Modularisation Remember the prime checker program:
Elements of Computing Systems, Nisan & Schocken, MIT Press, Chapter 1: Boolean Logic slide 1www.nand2tetris.org Building a Modern.
Elements of Computing Systems, Nisan & Schocken, MIT Press, Chapter 1: Boolean Logic slide 1www.idc.ac.il/tecs Boolean Logic Elements.
Sneha.  Gates Gates  Characteristics of gates Characteristics of gates  Basic Gates Basic Gates  AND Gate AND Gate  OR gate OR gate  NOT gate NOT.
Basic logic gates  AND gate:The truth table is given by A.BBA
Gates and Logic Dr John Cowell phones off (please)
Combination of logic gates  Logic gates can be combined to produce more complex functions.  They can also be combined to substitute one type of gate.
Prime Numbers Damian Gordon. Prime Numbers So let’s say we want to express the following algorithm: – Read in a number and check if it’s a prime number.
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
Thinking Mathematically Logic 3.4 Truth Tables for the Conditional and Biconditional.
Python: Structured Programming Damian Gordon. Structured Programming Remember the modularised version of the prime number checking program:
CS 270 Lecture 1 In Class Problems. Q1: Logic Puzzle You arrive at the end of a long hallway. There are two knights guarding two doors. One knight always.
 Conjunctive Normal Form: A logic form must satisfy one of the following conditions 1) It must be a single variable (A) 2) It must be the negation of.
Python: Menu-Driven Programs Damian Gordon. Menu-Driven Programs These are programs that display a menu (or list of options), and allows the user to choose.
Basic Gates and ICs 74LS00 Quad 2-Input NAND gate 74LS02 Quad 2-Input NOR gate 74LS04 Quad 2-Input NOT gate 74LS08 Quad 2-Input AND gate 74LS32 Quad 2-Input.
Logic Gates Learning Objectives Learn that there is a one-to-one relationship between logic gates and Boolean expressions Learn how logic gates are combined.
Logic Gates and Truth Tables
Eng. Mai Z. Alyazji October, 2016
Logic Gates.
Bool operators and, or, not
Logic Gates.
Logic Gates Benchmark Companies Inc PO Box Aurora CO
Basic Logical Operations (Fascinating)
Discrete Mathematics Lecture # 2.
KS4 Electricity – Electronic systems
KS4 Electricity – Electronic systems
Digital Signals Digital Signals have two basic states:
1.2 Propositional Equivalences
Propositional Equivalences
Agenda – 2/12/18 Questions? Readings: CSI 4, P
Types, Truth, and Expressions (Part 2)
Types, Truth, and Expressions (Part 2)
Types, Truth, and Expressions (Part 2)
Types, Truth, and Expressions (Part 2)
Logic Gates.
Queues: Implemented using Arrays
Logic Gates.
Practice with loops! What is the output of each function below?
KS4 Electricity – Electronic systems
GCSE Computer Science – Logic Gates & Boolean Expressions
Logic Gates.
Types, Truth, and Expressions (Part 2)
1.2 Propositional Equivalences
Statements of Symbolic Logic
Circular Queues: Implemented using Arrays
Truth tables Mrs. Palmer.
1.2 Propositional Equivalences
Section 3.3 Truth Tables for the Conditional and Biconditional
Truth Tables for the Conditional and Biconditional
Functional Notation Addendum to Chapter 4.
Eng. Ahmed M Bader El-Din October, 2018
Python Reserved Words Poster
Presentation transcript:

Python: Logic Gates Damian Gordon

AND gate simulation A AND B: A OUT B

AND gate simulation def AND(a,b): if a == True and b == True : return True else: return False # END AND.

NAND gate simulation Not of AND: A OUT B

NAND gate simulation def NAND(a,b): if a == True and b == True: return False else: return True # END NAND.

OR gate simulation A OR B: A OUT B

OR gate simulation def OR(a,b): if a == True: return True elif b == True: else: return False # END OR.

XOR gate simulation A XOR B: A OUT B

XOR gate simulation def XOR(a,b) : if a != b: return True else: return False # END XOR.

TAUTology gate simulation Always TRUE: A T TRUE B

TAUTology gate simulation def TAUT(a,b): return True # END TAUT.

Printing Truth Tables

NAND Truth Table print("+----------------------+--------------------+") print("| NAND Truth Table | Result |") print ("| A = False, B = False | A NAND B = ", NAND(False,False)," |") print ("| A = False, B = True | A NAND B = ", NAND(False,True)," |") print ("| A = True, B = False | A NAND B = ", NAND(True,False)," |") print ("| A = True, B = True | A NAND B = ", NAND(True,True),"|")

NAND Truth Table +----------------------+--------------------+ | NAND Truth Table | Result | | A = False, B = False | A NAND B = True | | A = False, B = True | A NAND B = True | | A = True, B = False | A NAND B = True | | A = True, B = True | A NAND B = False |

XOR Truth Table print("+----------------------+-------------------+") print("| XOR Truth Table | Result |") print ("| A = False, B = False | A XOR B = ", XOR(False,False),"|") print ("| A = False, B = True | A XOR B = ", XOR(False,True)," |") print ("| A = True, B = False | A XOR B = ", XOR(True,False)," |") print ("| A = True, B = True | A XOR B = ", XOR(True,True),"|")

XOR Truth Table +----------------------+-------------------+ | XOR Truth Table | Result | | A = False, B = False | A XOR B = False | | A = False, B = True | A XOR B = True | | A = True, B = False | A XOR B = True | | A = True, B = True | A XOR B = False |

etc.