Computer Programming Boolean Logic Trade & Industrial Education

Slides:



Advertisements
Similar presentations
1 Computer Programming Boolean Logic Copyright © Texas Education Agency, 2013.
Advertisements

INTRODUCTION LOGICAL OPERATIONS TRUTH TABLE AND RULES.
1 If Control Construct A mechanism for deciding whether an action should be taken JPC and JWD © 2002 McGraw-Hill, Inc.
ALGEBRA 1 BASICS CHEAT SHEET THINGS YOU SHOULD KNOW . . .
If Statements & Relational Operators Programming.
BOOLEAN LOGIC CSC 171 FALL 2004 LECTURE 7. ASSIGNMENT Review Quiz # 2 Start reading Chapter 5.
Chapter 4 Logic Gates and Boolean Algebra. Introduction Logic gates are the actual physical implementations of the logical operators. These gates form.
HAWKES LEARNING SYSTEMS math courseware specialists Copyright © 2010 Hawkes Learning Systems. All rights reserved. Hawkes Learning Systems: College Algebra.
Logic Gate A logic gate is an electronic circuit which makes logic decisions. It has one output and one or more inputs. The output signal appears only.
Computer Science 101 Boolean Algebra. What’s next? A new type of algebra – Helps us A new type of algebra – Helps us With logical reasoningWith logical.
Digital Logic Circuits – Chapter 1 Section 1-3, 1-2.
Logical Circuit Design Week 5: Combinational Logic Circuits Mentor Hamiti, MSc Office ,
AP Examination Alert The APCS Examination includes a variety of Boolean Logic questions. Many questions require indirect knowledge of Boolean Logic, and.
Computer Science 101 The Boolean System. George Boole British mathematician ( ) Boolean algebra –Logic –Set theory –Circuits –Conditions in if.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 4 Decision Structures and Boolean Logic.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Chapter 2: Binary Logic.
Logic gates & Boolean Algebra. Introduction Certain components (called logic elements) of the computer combine electric pulses using a set of rules. Electric.
Lecture 7 How computers process data (Number Systems) PRESENTED BY MD. MAHBUBUL ALAM, PHD 1.
Boolean Algebra By Lindsey Curtis & Tomas Filip. Boolean Algebra An abstract mathematical system used to describe relationships between sets Mainly used.
CSC 107 – Programming For Science. Follow-Up From Last Lecture.
The Language of Algebra
Decision Structures and Boolean Logic
Computer Science 210 Computer Organization Introduction to Boolean Algebra.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 4 Decision.
Semester 1 Final Review Lesson 1.1 Variables in Algebra Evaluate the variable expression when x = x.
Chapter 1: The Language of Algebra You will learn: To use variables to represent unknown quantities Words to Learn: Variables: letters used to ______________.
Chapter 5 Logic; Got Any?. Flow of Control The order in which the computer executes statements in a program Control Structure A statement used to alter.
CSC 107 – Programming For Science. George Boole  Mathematician from English middle-class  Lived from 1815 – 1864  Started work at age 16 as a teaching.
IB Computer Science – Logic
Boolean values Gateway to decision making. Background Our problem-solving solutions so far have the straight-line property –They execute the same statements.
COMPUTER ARCHITECTURE TRUTH TABLES AND LOGIC GATES.
Laws of Boolean Algebra Commutative Law Associative Law Distributive Law Identity Law De Morgan's Theorem.
Chapter 4 Fundamentals of Computer Logic 1 Chapter 4: Fundamental of Computer Logic - IE337.
§ 1.9 Exponents, Parentheses and Order of Operations.
Write as an Algebraic Expression The product of a number and 6 added to a.
Operators.
Logical Thinking CS 104 9/12/11. Agenda Today  College Board survey reminder  Note: Simple “how to” guide on Scratch posted on eLearning  Review HW.
5.02B Decision Making Structure (part 2). Compound Boolean Expressions.
Boolean Algebra. BOOLEAN ALGEBRA Formal logic: In formal logic, a statement (proposition) is a declarative sentence that is either true(1) or false (0).
DIGITAL ELECTRONICS. Everything in digital world is based on binary system. Numerically it involves only two symbols 0 or 1. –0 = False = No –1 = True.
3 + 6a The product of a number and 6 added to 3
Math 094 Section 1.3 Exponents, Order of Operations, and Variable Expressions.
Opener: Find three consecutive odd integers whose sum is -63 Integer #1 = n Integer #2 = n + 2 Integer #3 = n + 4 (n) + (n + 2) + (n + 4) = -63 3n + 6.
CMSC201 Computer Science I for Majors Lecture 05 – Comparison Operators and Boolean (Logical) Operators Prof. Katherine Gibson Prof. Jeremy.
Computer Programming Boolean Logic.
Logic gates.
CPS120 Introduction to Computer Science
Computer Code.
Computer Science 210 Computer Organization
Logic Gates and Boolean Algebra
Section 7.1 Logical Operators
COMPUTING FUNDAMENTALS
Introduction To Robot Decision Making
Operators and Expressions
Boolean Algebra Digital Electronics
Computer Science 210 Computer Organization
GCSE Computer Science – Logic Gates & Boolean Expressions
Introduction To Robot Decision Making
Chapter 1 Section 1 Algebraic Expressions, Real Numbers, and Interval Notation.
Lecture 5 Binary Operation Boolean Logic. Binary Operations Addition Subtraction Multiplication Division.
ECS15 boolean.
Truth tables Mrs. Palmer.
Section 6.1 Order of Operations
Section 6.1 Order of Operations
Algebra: Variables and Expressions
Computer Programming Boolean Logic Trade & Industrial Education
5.03 Apply operators and Boolean expressions
Conditionals.
Bell Work!!! Directions: Write out the exponent in word form. 3^6 6^4
Presentation transcript:

Computer Programming Boolean Logic Trade & Industrial Education Copyright © Texas Education Agency, 2013 Trade & Industrial Education

What is Boolean Logic? Boolean logic is a system for determining the truth of a statement (or expression) based on whether certain variables are true or false. For example: In the statement, “I will go for a walk if it is sunny,” the decision is based on whether it is true that it is ‘sunny.’ © UNT in partnership with TEA Copyright © Texas Education Agency, 2013 IT: [Computer Programming] - [Boolean Logic] 2 Trade & Industrial Education

Historical Note George Boole (1815-1864) was an English mathematician who devised a system of symbols and equations to represent logical decisions. Boolean Algebra was not widely used until the invention of computers. Boolean logic expressions are used to design electronic circuits and to represent decision-making in software Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 3 Trade & Industrial Education

How is Boolean Logic used? A combination of conditions, variables, and operators are used to determine if an expression is True or False. It can also be used to determine which elements can be members of a given set. Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 4 Trade & Industrial Education

How are these categories different? Brown-eyed AND Male Brown-eyed OR Male Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 5 Trade & Industrial Education

Who would be in these groups? NOT male AND wearing jeans NOT <16 Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 6 Trade & Industrial Education

Like Mathematics, Boolean logic has operators Mathematic Operators + - x / = Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 7 Trade & Industrial Education

Boolean Operators && ( AND ) || ( OR ) ! ( NOT ) Cheese || Pepperoni && !Anchovies Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 8 Trade & Industrial Education

Like Math, Boolean logic has an order of operations Mathematic Order of Operations is PEMDAS Parentheses first Exponents next Multiplication and Division Addition and Subtraction Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 9 Trade & Industrial Education

Order of Boolean Operations Parentheses are not operators, but indicate grouping, consider these first. NOT (!) must be considered next. AND ( && ) is considered next. OR ( || ) is considered last. Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 10 Trade & Industrial Education

!Tall && Blonde || Rich Consider the NOT first. !Tall is short. Consider the AND next. !Tall and Blonde, in other words, Short and Blonde. Consider the OR next. This person can be either Short and Blonde, or they can be Rich. They can also be Short, Blonde, and Rich. Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 11 Trade & Industrial Education

Order of Operations Parentheses first, then NOT (!) , then && , then || !Tall && Blonde || Rich !(Tall && Blonde) || Rich !Tall && !Blonde || Rich Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 12 Trade & Industrial Education

Venn Diagrams Venn Diagrams can be used to visualize Boolean expressions. Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 13 Trade & Industrial Education

Venn Diagram B A A && B Trade & Industrial Education Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 14 Trade & Industrial Education

Where is !A B A Trade & Industrial Education Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 15 Trade & Industrial Education

Where is A || B ? B A Trade & Industrial Education Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 16 Trade & Industrial Education

Truth Tables Truth tables are used to evaluate possible combinations of variables and operators. Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 17 Trade & Industrial Education

A || B (A OR B) A B A || B True False Trade & Industrial Education © UNT in partnership with TEA Copyright © Texas Education Agency, 2013 IT: [Computer Programming] - [Boolean Logic] 18 Trade & Industrial Education

A && B (A AND B) A B A && B True False Trade & Industrial Education © UNT in partnership with TEA Copyright © Texas Education Agency, 2013 IT: [Computer Programming] - [Boolean Logic] 19 Trade & Industrial Education

!A (NOT A) A !A True False Trade & Industrial Education © UNT in partnership with TEA Copyright © Texas Education Agency, 2013 IT: [Computer Programming] - [Boolean Logic] 20 Trade & Industrial Education

!A || B (NOT A OR B) A B !A || B True False © UNT in partnership with TEA Copyright © Texas Education Agency, 2013 IT: [Computer Programming] - [Boolean Logic] 21 Trade & Industrial Education

Check for Understanding Determining the results of a Boolean expression is known as evaluating it. All Boolean expressions evaluate to either True or False Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 22 Trade & Industrial Education

Evaluate: What would be printed, A or B? boolean blonde = false; if ( blonde) System.out.println(“A”); if ( !blonde) System.out.println(“B”); Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 23 Trade & Industrial Education

Evaluate: What would be printed, A or B? boolean tall = false; boolean male = true; if ( male && tall) System.out.println(“A”); if ( male || tall) System.out.println(“B”); Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 24 Trade & Industrial Education

Evaluate: What would be printed, A or B? boolean x = false; boolean y = true; if ( x && y) System.out.println(“A”); if ( !x && y) System.out.println(“B”); Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 25 Trade & Industrial Education

Shade in A || !B B A Trade & Industrial Education Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 26 Trade & Industrial Education

Shade in A && !B B A Trade & Industrial Education Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 27 Trade & Industrial Education

Shade in !A && !B B A Trade & Industrial Education Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 28 Trade & Industrial Education

Will it print? boolean x = true; boolean y = false; if ( x && !y) System.out.print(“A”); Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 29 Trade & Industrial Education

Will it print? boolean x = true; boolean y = false; if (! x || y) System.out.print(“A”); Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 30 Trade & Industrial Education

With what you know… Can you evaluate a boolean expression? Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 31 Trade & Industrial Education