Computer Logic
Logical Operators
 Logical operators are ways in which
we can create more complex
conditional statements.
 More efficient code
 Computer ranges of values
 A logical operator is formed by
usually combining 2 conditional
statements utilizing
 and
 or
 not
Logical Operators
 The computer evaluates the 1st statement and
then the 2nd statement
 Question: Why is this a more efficient way? Think
of the and/or situations separately?
 Fist statement And Second statement
 For a True-response both statements have to be true
 Fist statement Or Second statement
 For a true response only 1 statement has to be true
 They can even include more than 2 conditional
statements. 3, 4, or however many as you like.
 You can work with or’s or and’s in a statement.
 Question: Which Operator takes precedence and
why? Think order of Ops
Exercise
 Exploring logical values and truth tables
 Truth Tables Exercise
 Assume p = driving fast q = w/o a seat belt
 Chances of getting a ticket
p q p And q
1 1 1
0 1 0
1 0 0
0 0 0
Checkpoint
 1. (True and False )  _____
 2. (False or True)  ______
 3. (True and True) and (True or False)  ____
 4. !(False or True)  ____

Computer Logic

  • 1.
  • 2.
    Logical Operators  Logicaloperators are ways in which we can create more complex conditional statements.  More efficient code  Computer ranges of values  A logical operator is formed by usually combining 2 conditional statements utilizing  and  or  not
  • 3.
    Logical Operators  Thecomputer evaluates the 1st statement and then the 2nd statement  Question: Why is this a more efficient way? Think of the and/or situations separately?  Fist statement And Second statement  For a True-response both statements have to be true  Fist statement Or Second statement  For a true response only 1 statement has to be true  They can even include more than 2 conditional statements. 3, 4, or however many as you like.  You can work with or’s or and’s in a statement.  Question: Which Operator takes precedence and why? Think order of Ops
  • 4.
    Exercise  Exploring logicalvalues and truth tables  Truth Tables Exercise  Assume p = driving fast q = w/o a seat belt  Chances of getting a ticket p q p And q 1 1 1 0 1 0 1 0 0 0 0 0
  • 5.
    Checkpoint  1. (Trueand False )  _____  2. (False or True)  ______  3. (True and True) and (True or False)  ____  4. !(False or True)  ____

Editor's Notes

  • #3 I like when you tries to incorporate these even even you syntactically got it wrong but logically were correct. These are the people I help before the topic is taught not people that don’t even try or take the leap of faith.