170 likes | 183 Views
Learn how Boolean logic serves as the foundation for computer operations and how to apply it effectively in spreadsheets. Discover Boolean variables, operations, and logic basics. Practice De Morgan’s Laws and solve practical problems using Boolean formulas in Excel.
E N D
Boolean Algebra && how we might use it in spreadsheets Belinda Kerchmar 2.24.11
Boolean Logic • Invented by George Boole • Boolean logic is the basis for modern computer logic.
Quick Review: Variables • Where are variables in excel held? • What types of variables can we have? (In other words, what can be held in a cell?)
What is a Boolean Variable? • A variable (cell) that holds either true or false • In excel, can also be seen as 1 or 0 • Can be thought of conceptually as yes or no
Boolean Operations • In Math, there are operations: plus, minus, times, etc. • In Boolean Algebra, there are operations as well. • Boolean Operations: • AND • OR • NOT
Boolean Logic • Boolean logic Basics: • AND • OR • NOT
Intuitive vs. Excel • Over the course of the lecture, I’ll use a syntax like this: a AND b AND c • The same expression in excel would look like: AND(a,b,c)
AND • If every boolean being “and-ed” is true, then the AND operator returns true. • true AND true AND true = true • true AND false AND true = false
AND • In excel: AND (some list of arguments) • If everything in list of arguments is true, then AND returns true. Otherwise, AND returns false. • Did all students pass the course?
OR • If some boolean being “or-ed” is true, then the OR operator returns true • false OR false OR false = false • false OR false OR true = true
OR • In excel: OR(some list of arguments) • If at least one of the list of arguments is true, then OR returns true. • Did at least one student pass?
NOT • NOT(one argument) • If p is true, then NOT p is false. • If p is false, then NOT p is true.
NOT • NOT (circles) • blue & white • NOT(diagrams) • yellow & white • NOT(circles OR diagrams) • white • NOT(circles AND diagrams) • yellow, blue, white • Did neither student pass the course?
Properties • Just as in Math, the operations in Boolean Algebra follow certain properties.
De Morgan’s Laws • NOT (P AND Q) = • (NOT P) OR (NOT Q) • NOT (P OR Q) = • (NOT P) AND (NOT Q)
On your own (or in groups) • Download Spreadsheet from course website • Write formulas to determine the following information for each item: • Is it tasty and healthy? • Is it dinner, but not tasty? • Is it dinner, and healthy or tasty? • Is it healthy, but not tasty or a snack?