Upcoming SlideShare
×

Ch 5 boolean logic

2,524 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
2,524
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
29
0
Likes
0
Embeds 0
No embeds

No notes for slide
• The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
• The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
• The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
• The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
• The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
• The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
• The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
• Ch 5 boolean logic

1. 1. Boolean Logic
2. 2. George Boole <ul><li>In1854, George Boole published “ An investigation into the Laws of Thought, on which are founded the Mathematical Theories of Logic and Probabilities.” </li></ul><ul><li>Boole outlined a system of logic and a corresponding algebraic language dealing with true and false values. </li></ul>100 th Anniversary Edition
3. 3. Boolean Logic <ul><li>Boolean logic is a form of mathematics in which the only values used are true and false. </li></ul><ul><li>Boolean logic is the basis of all modern computing. </li></ul><ul><li>There are three basic operations in Boolean logic – AND, OR, and NOT. </li></ul>100 th Anniversary Edition
4. 4. The AND Operation <ul><li>The AND operation is a binary operation, meaning that it needs two operands. </li></ul><ul><li>c = a AND b </li></ul><ul><li>Both a and b must be true for the result to be true. </li></ul>F F F F T T a F T b AND
5. 5. The OR Operation <ul><li>The OR operation is also a binary operation with two operands. </li></ul><ul><li>c = a OR b </li></ul><ul><li>If either a OR b is true, then the result is true. </li></ul>F T F T T T a F T b OR
6. 6. The NOT Operation <ul><li>The NOT operation is a unary operation with only one operand. </li></ul><ul><li>c = NOT (a) </li></ul><ul><li>It simply reverses the true or false value of the operand. </li></ul>T F F T a NOT
7. 7. Logical Conditions <ul><li>Logical comparisons that are either true or false are most often used as the basis for the true and false values in Boolean logic. </li></ul><ul><li>They are often used for simple conditions in branching and looping instructions. </li></ul>If (hours > 40) pay overtime If (age < 12) stay in the back seat While (count  10) print count increment count
8. 8. Logical Comparison Operators <ul><li>Six different comparison operators are used in mathematics and computer programming. </li></ul>A  B A  B A > B A < B A  B A = B In Math A >= B A is greater than or equal to B A <= B A is less than or equal to B A > B A is greater than B A < B A is less than B A<> B or A != B A is not equal to B A = B or A == B A equals B In Programming Condition
9. 9. Compound Conditions <ul><li>Compound Boolean conditions can be created using the Boolean AND, OR and NOT operations in branching and looping instructions. </li></ul>If ( (hours > 40) AND (type = hourly) ) pay overtime If ( (age < 12) OR (height < 42 in.) ) stay in the back seat While ( (count <= 10) AND NOT (status = away) ) print name.count increment count
10. 10. Boolean Logic in Alice
11. 11. Boolean Functions Functions in Alice that return true or false values are called Boolean functions. Alice has many such built-in functions, such as these two groups of basic Boolean logic functions and comparison functions.
12. 12. They can be found on the world’s functions tab
13. 13. They are used inside branching and looping instruction tiles
14. 14. Boolean Functions The Boolean comparison functions can be used to create simple true or false conditions.
15. 15. Boolean Functions The Boolean logic functions can be used to create compound conditions.
16. 16. Boolean Functions Alice has many other world-level and object-level fuctions that return true or false values, such as the Boolean proximity functions shown here on aliceLiddel’s functions tab in the details area.
17. 17. Boolean Functions They can be used anywhere that a Boolean value is needed, such as in this If/Else command.