300 likes | 425 Views
Computer Science & Engineering 2111. Lecture 3 IF and Boolean Functions. IF FUNCTION. Checks to see if a condition is true or false. If true one thing happens, if false another thing happens IF this is true, do this, else do this. =IF(logical test, value_if_true , [ value_if_false ])
E N D
Computer Science & Engineering 2111 Lecture 3 IF and Boolean Functions CSE 2111 Lecture 3-IF and Boolean Functions
IF FUNCTION Checks to see if a condition is true or false. If true one thing happens, if false another thing happens • IF this is true, do this, else do this. =IF(logical test, value_if_true, [value_if_false]) • Logical test must evaluate to true or false CSE 2111 Lecture 3-IF and Boolean Functions
NESTED IF • IF this is true, do this, else IF this is true, do this, else, do this. =if(this = true, do this, else if(this = true, do this, otherwise do this)) • Can be nested up to 7 times. CSE 2111 Lecture 3-IF and Boolean Functions
Assume no student has the same score. CSE 2111 Lecture 3-IF and Boolean Functions
IF with a range CSE 2111 Lecture 3-IF and Boolean Functions
Using Boolean functions =AND(logical1, [logical2], …) • Returns true if all arguments evaluate to true =OR(logical1, [logical2], …) • Returns true if at least one argument evaluates to true =NOT(logical) • Changes false to true and true to false CSE 2111 Lecture 3-IF and Boolean Functions
Scores Statistics CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F2 to determine T/F if Led Zeppelin’s total score is higher than Rob Thomas’ total score. CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F3 to determine T/F if Rob Thomas’ total score is the maximum in the class. CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F4 to determine T/F if the average total score of all students is less than 300. CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F5 to determine T/F if everyone passed the class. (A passing score is 320) =AND(Scores!E5>=Scores!B2, Scores!E6>=Scores!B2,Scores!E7>=Scores!B2) CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F6 to determine T/F if all the students are honors students. DON’T DO THIS =AND(Scores!F5=True,Scores!F6=True,Scores!F7=True) AND REALLY, DON’T DO THIS =AND(Scores!F5=“True”,Scores!F6=“True”,Scores!F7=“True”) CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F7 to determine T/F if Led Zeppelin’s total score and Rob Thomas’ total score is greater than Rascal Flat’s total score. CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F8 to determine T/F if as least one person passed the class. =OR(Scores!E5>=Scores!B2, Scores!E6>=Scores!B2,Scores!E7>=Scores!B2) CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F9 to determine T/F if at least one person is an honors student. CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F10 to determine T/F if Led Zeppelin is not an honors student. CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F11 to determine T/F if none of the students are honors students. Another possible answer: =NOT(F6) Another possible answer: =AND(NOT(Scores!F3), NOT(Scores!F4),NOT(Scores!F5)) CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F12 to determine T/F if none of the students passed the course. =NOT(OR(Scores!E5<Scores!B2,Scores!E6<Scores!B2,Scores!E7<Scores!B2)) Another possible answer: =NOT(F5) CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F13 to determine T/F if only Led Zeppelin passed the course. =AND(Scores!E5>=Scores!B2, NOT(OR(Scores!F6>=Scores!B2, Scores!E7>=Scores!B2))) Another possible answer: =AND(Scores!E5>=Scores!B2,NOT(F5)) CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell Statistics!F14 to determine T/F if Rob Thomas’ score is at least 15 points higher than Rascal Flat’s Total Score. CSE 2111 Lecture 3-IF and Boolean Functions
Scores New Stats CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell NewStats!F2 to determine if everyone passed the class. (A passing score is 320)Display the text, “Everyone”, or “Not Everyone” =IF(AND(Scores!E5>=Scores!B2,Scores!E6>=Scores!B2,Scores!E7>=Scores!B2),"Everyone", "Not Everyone") CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell New Stats!F3 to determine if all the students are honors students.Display the text, “All Honor Students”, or “Not Everyone is an Honor’s student” =IF(AND(Scores!F5:F7),"All Honor Students", "Not Everyone is an Honors student") CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell New Stats!F4 to determine if Led Zeppelin’s total score and Rob Thomas’ total score is greater than Rascal Flat’s total score.Display the text, “Led and Rob”, or Rascal” =IF(AND(Scores!E5>Scores!E7,Scores!E6>Scores!E7), "Led and Rob", "Rascal") CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell New Stats!F5 to determine if at least one person passed the class.Display the text, “At least one passed” or “No One passed” =IF(OR(Scores!E5>=Scores!B2,Scores!E6>=Scores!B2,Scores!E7>=Scores!B2),"At least one passed", "No One passed") CSE 2111 Lecture 3-IF and Boolean Functions
Write a formula in cell New Stats!F6 to determine if at least one person is an honors student.Display the text, “At least one Honors student”, or “No Honor students”) =IF(OR(Scores!F5:F7),"At least one Honors student", "No Honor students") CSE 2111 Lecture 3-IF and Boolean Functions