logical
play

Logical Operators How do we form compound logical statements? IF - PowerPoint PPT Presentation

Logical Operators How do we form compound logical statements? IF there is a pandemic AND I am in public, THEN I'll wear a mask. IF it is raining OR it is cold, THEN I'll grab my jacket. IF it is NOT a COMP110 assignment, THEN I will


  1. Logical Operators

  2. How do we form compound logical statements? • IF there is a pandemic AND I am in public, THEN I'll wear a mask. • IF it is raining OR it is cold, THEN I'll grab my jacket. • IF it is NOT a COMP110 assignment, THEN I will procrastinate.

  3. The operator truth table • The keyword is a boolean operator True False [boolean a] [boolean b] True True False False False False boolean value You read a truth table like a multiplication table. Start with a finger on one column label and one • If both expressions connected by the symbol are row label, per each side of the True , then the resulting boolean will be True . Otherwise it operator, and trace your way in. will be False .

  4. The operator truth table • The keyword is a boolean operator True False [boolean a] [boolean b] True True True False True False boolean value You read a truth table like a multiplication table. Start with a finger on one column label • If either expression connected by the symbol is and one row label, per each side True , then the resulting boolean will be True . of the operator, and trace your Otherwise it will be False . way in.

  5. The operator truth table • The keyword is a unary boolean operator. True False [ boolean a] not False True boolean value • The expression following the operator will evaluate to the opposite boolean value. True becomes False and False becomes True.

  6. Logical Operator Reference and or not Expression Evaluates to Expression Evaluates to Expression Evaluates to It is worth committing these to memory. Every programming language (including Excel) shares the same ideas of logical operators.

Recommend


More recommend