Download presentation
Presentation is loading. Please wait.
Published bySharyl Fletcher Modified over 5 years ago
1
Computer Programming Boolean Logic Trade & Industrial Education
Copyright © Texas Education Agency, 2013 Trade & Industrial Education
2
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
3
Historical Note George Boole ( ) 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
4
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
5
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
6
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
7
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
8
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] 8 Trade & Industrial Education
9
Order of Boolean Operations
1. Parentheses are not operators, but indicate grouping, consider these first. 2. == 3. != 4. not 5. and 6. or is considered last. p == q p != q not p p and q p or q © UNT in partnership with TEA Copyright © Texas Education Agency, 2013 IT: [Computer Programming] - [Boolean Logic] 9 Trade & Industrial Education
10
not Tall and Blonde or Rich
Consider the NOT first. Not Tall is short. Consider the AND next. Not 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] 10 Trade & Industrial Education
11
Order of Operations Parentheses first, then not, then and, then or
Not Tall and Blonde or Rich Not (Tall and Blonde) or Rich Not Tall and not Blonde or Rich Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 11 Trade & Industrial Education
12
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] 12 Trade & Industrial Education
13
Venn Diagram B A A and B Trade & Industrial Education
Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 13 Trade & Industrial Education
14
Where is not A? B A Trade & Industrial Education
Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 14 Trade & Industrial Education
15
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] 15 Trade & Industrial Education
16
A OR B A B A or B True False Trade & Industrial Education
© UNT in partnership with TEA Copyright © Texas Education Agency, 2013 IT: [Computer Programming] - [Boolean Logic] 16 Trade & Industrial Education
17
A AND B A B A and B True False Trade & Industrial Education
© UNT in partnership with TEA Copyright © Texas Education Agency, 2013 IT: [Computer Programming] - [Boolean Logic] 17 Trade & Industrial Education
18
NOT A A not A True False Trade & Industrial Education
© UNT in partnership with TEA Copyright © Texas Education Agency, 2013 IT: [Computer Programming] - [Boolean Logic] 18 Trade & Industrial Education
19
not A or B A B not A or 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
20
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] 20 Trade & Industrial Education
21
Evaluate: What would be printed, A or B?
blonde = False if blonde: print ‘A' if not blonde: print ‘B‘ Answer is B Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 21 Trade & Industrial Education
22
Evaluate: What would be printed, A or B?
tall = False female = True if ( female and tall): print 'A' if ( female or tall): print 'B‘ Answer is B Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 22 Trade & Industrial Education
23
Evaluate: What would be printed, A or B?
x = False y = True if ( x and y): print ‘A’ if ( not x and y): print ‘B’ Answer: B Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 23 Trade & Industrial Education
24
Shade in A and not B B A Trade & Industrial Education
Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 24 Trade & Industrial Education
25
Shade in not A and not B B A Trade & Industrial Education
Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 25 Trade & Industrial Education
26
Will it print? x = True y = False if ( x and not y): print ‘a’
Yes Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 26 Trade & Industrial Education
27
Will it print? x = True y = False if (not x or y): print ‘a’
Copyright © Texas Education Agency, 2013 © UNT in partnership with TEA IT: [Computer Programming] - [Boolean Logic] 27 Trade & Industrial Education
28
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] 28 Trade & Industrial Education
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.