Presentation is loading. Please wait.

Presentation is loading. Please wait.

New Mexico Computer Science For All Booleans and Logic Maureen Psaila-Dombrowski.

Similar presentations


Presentation on theme: "New Mexico Computer Science For All Booleans and Logic Maureen Psaila-Dombrowski."— Presentation transcript:

1 New Mexico Computer Science For All Booleans and Logic Maureen Psaila-Dombrowski

2 Boolean Boolean - EASY  Can have one of two values ▫true or false ▫on or off ▫1 or 0 Boolean Expressions  Evaluate to be true or false Boolean Operators  Operators that are used with Booleans Boolean Math/Algebra or Boolean Logic  Uses Booleans and Boolean operators  Used in computers

3 Boolean Expressions A simple use of Boolean concept Expressions that evaluate to True or False They use comparison operators (=,, =)  Compare two sides – numbers, variables, expressions  Ask a specific question – Is the expression TRUE or FALSE ? You have used them in math before. 24 + 13 = ? Addition  37 24 + 13 = 37 ? Boolean  true 24 + 13 = 40 ? Boolean  false

4 Boolean Expressions (continued) Expression (Comparison Operator) Question Asked L=RThe left equals the right, True or False? 3 + 5=83 + 5 equals 8, True or False?  TRUE L<RThe left is less than the right, True or False? 16/4<316/4 is less than 3, True or False?  FALSE L>RThe left is greater than the right, True or False? 50*100>50050*100 is greater than 500, True or False?  TRUE

5 Boolean Operators Three basic ones: AND, OR, NOT  Most other operators are based on these Compares Boolean values or expressions or change them Evaluates to a Boolean (True or False, On or Off, 1 or 0) Rules for each operator are different Boolean Value Or Expression (True or False) Boolean Operator Boolean Value Or Expression (True or False) Boolean Value (True or False)

6 Boolean Logic Also know as Boolean Algebra or Boolean Math What is it? ▫Only two values. ▫The Math of comparing and manipulating Booleans So what? ▫Most important principle of modern computers. Developed in the 1850s by George Boole ▫A founder of computer science

7 Boolean Logic Expression: A AND B For A AND B to be true BOTH A AND B must be true (Both Sides Must Be True) AND Truth Table: Boolean Logic (continued) AND A Boolean Expression Boolean Operator B Boolean Expression Evaluates to TRUEANDTRUE ANDFALSE ANDTRUEFALSE ANDFALSE

8 Boolean Logic Lets look at an example: Marbles

9 Boolean Logic Lets look at an example: Marbles Blue? = false Red? = true Marble? = true Blue? = false Red? = true Marble? = true

10 Boolean Logic We can group the marbles: Is there a set of Marble? = true Marble? = true

11 Boolean Logic Blue? = true Red? = true We can also group the marbles: The marble is Blue? = true ? The marble is Red? = true ?

12 Boolean Logic Blue? = true Red? = true Is there a set: (Marble? = true) AND (Blue? = true) is true Is there a set: (Blue? = true) AND (Red? = true) is true?

13 Blue? = true Red? = true Boolean Logic Find the set with (Blue? = true) AND (Red? = true) Find the set with (Blue? = true) AND (Green? = true) Find the set with (Purple? = true) AND (Green? = true)

14 For A OR B to be true EITHER A OR B can be true (Only One Side Needs to be True) OR Truth Table: Boolean Logic (continued) OR A Boolean Expression Boolean Operator B Boolean Expression Evaluates to TRUEORTRUE ORFALSETRUE FALSEORTRUE FALSEORFALSE

15 Blue? = true Red? = true Find the set with (Blue? = true) OR (Red? = true) Boolean Logic (continued)

16 Find the set with (Blue? = true) OR (Red? = true) Find the set with (Blue? = true) OR (Green? = true) Find the set with (Purple? = true) OR (Green? = true) Boolean Logic (continued)

17 NOT Boolean Operator Boolean Expression Evaluates to NOTTRUEFALSE NOTFALSETRUE NOT is really easy – it just gives you the opposite value

18 Blue? = true Red? = true Find the set with (NOT Blue? = true) Find the set with (NOT Red? = true) Find the set with (NOT Purple? = true) Boolean Logic (continued)

19 Find the set with (NOT Red? = true) Find the set with (NOT Blue? = true) Find the set with (NOT Purple? = true) Boolean Logic (continued)

20 Order of Operation 1.Parenthesis 2.NOT 3.AND 4.OR Examples: NOT true AND true  false AND true  FALSE NOT ( false AND true )  NOT false  TRUE true OR false AND true  true OR false  TRUE ( true OR false ) AND true  true AND true  TRUE Boolean Logic (continued)

21 Booleans in Computer Science Search Engines (Average User) ▫Use Boolean Logic to limit: AND, OR, NOT ▫Boolean Order of Operations holds Conditionals (Programmer) ▫Boolean Expressions and Boolean Logic ▫Used in Conditionals

22 Booleans in Computer Science Digital Gates (Boolean Gates) in Chips/Circuits (Hardware Engineer) ▫Fundamental building block of a computer ▫Uses Booleans  True and False  1’s and 0’s ▫Boolean Logic  To figure out if gate is open/closed

23 Summary Booleans can have only two values Boolean expressions  Use comparison operators (=, )  Evaluate to TRUE or FALSE Boolean Operators  Three Basic Operators: AND, OR, NOT  Compare Boolean values/expressions or change them  Evaluate to TRUE or FALSE Boolean Logic Use Boolean Operators: AND, OR, NOT The math of comparing and manipulating Booleans. Order of Operation: ( ), NOT, AND, OR


Download ppt "New Mexico Computer Science For All Booleans and Logic Maureen Psaila-Dombrowski."

Similar presentations


Ads by Google