Download presentation
Presentation is loading. Please wait.
1
&& how we might use it in spreadsheets
Conditional Logic && how we might use it in spreadsheets
2
Boolean Logic Invented by George Boole
Boolean logic is the basis for modern computer logic. George Boole was an english mathematician and philosopher. Born 1815, died 1864.
3
Boolean Logic Boolean logic Basics: AND OR NOT
Which color represents Circles & Diagrams: green Circles Or Diagrams: yellow, blue, green Not Circles -- blue & white Not Diagrams -- yellow & white
4
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? easy example: =AND(2 + 2 = 4), =AND(2+3 = 4), AND(2 + 2 = 4, = 4) harder example: Did both students pass the course? =AND(H2>=60, I2 >=60, J2 >=60) p q p and q T F
5
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? Note: Or does not mean that you have to have either one or the other. It simply means that you have at least one from the list. easy example: OR(2+2=4, 2+5=4) easy example: OR(2+2=3, 2+4=3) Did at least one student pass? =OR(H2>=60, I2 >=60, J2 >=60) p q p or q T F
6
NOT NOT(one argument) If p is true, then NOT p is false.
If p is false, then NOT p is true. p not p T F
7
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? simple example: not(2+2=4) = FALSE not(2+3=5) = TRUE more complicated example -- neither student passes: =NOT(AND(H2>=60, I2 >=60, J2 >=60)) notice: NOT(AND(H2 >= 60, I2 >=60, J2>-60) == AND(H2 < 60, I2 < 60, J2<60)
8
Some Other Operators IF SUMIF COUNTIF
9
IF IF In the real world... IF, THEN, ELSE
excel: IF(logical_test, valueIfTrue, valueIfFalse) We use if-then-else statements in the real world all the time! If you go to bed, you’ll feel fresh in the morning, else (if you don’t go to bed) you’ll feel tired. If you’re a carolina fan on game day, then you wear blue, otherwise you don’t.
10
IF examples... Let’s assign letter grades to the students! 90-100 -A
B C D <60 - F easy if: =IF(A1 > 7, "Greater than Seven","Less than Seven") note: make sure to use >= or <= because what if you type in 7? you need to cover all cases! Nested If: =IF(H2>=90, “A”, If(H2 >=80, “B”, “C or Below”)) Longer Nested if: =IF(H2>=90, "A", IF(H2>=80, "B", IF(H2>=70, "C", IF(H2 >=60, "D", "Fail"))))
11
COUNTIF in excel COUNTIF(range, criteria) range example: I2: I9
criteria example: “>= 60” criteria needs to be in quotes. How many courses is each student passing? How many courses did at least one student pass? example: number of courses passing: =COUNTIF(H2:H9, ">=60") & =COUNTIF(I2:I9, ">=60") & =COUNTIF(J2:J9, “>=60”) example: number of courses in which at least one student passed: =COUNTIF(L2:L9, TRUE)
12
SUMIF in excel: SUMIF(range, criteria, sum_range)
this function will add things up, depending on the criteria given. If we bought one of each fruit, how much would it cost? If we bought one of each vegetable, how much would it cost? =SUMIF(C45:C50,"Fruit",B45:B50) =SUMIF(C45:C50,"Vegetable",B45:B50)
13
On Your Own (or in groups)...
Buy the grocery item if it is a fruit and if it costs less than $2.50 Label the grocery items as inexpensive (<$1), medium ($1 - $2), Expensive (>$2) Sum up the even numbers from the list. Hint: ISEVEN(someNumber) ISODD(someNumber) Sum up the odd numbers from the list.
14
On Your Own (or in groups)...
Calculate the perimeter of the rectangle Calculate the area of the rectangle Calculate the ratio of the area to the rectangle (round this to the hundredths place)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.