Lecture 5 - Exercises

5A - Boolean Expressions and Operators

Evaluate each of the following boolean expressions:

  1. 4 > 6
  2. 5 <= 5
  3. 3 == 6
  4. 4 != 5
  5. True != True

Evaluate each of the following, keeping in mind order of operations.

  1. 10 == 4 + 6
  2. "abc" == "ab" + "c"
  3. 'abc' == "abc"
  4. "Scott" == "scott"
  5. (4+3 > 5) == (1.0 > 4)
  6. int(5.6) != int(5.1)

Evaluate the following expressions, writing out each step of simplification after an operator is evaluated to show the order of evaluation as we did in the Bigger Example from the lecture video.

  1. (3 == 5 or (3 != 5 and 5 != 7)) and 3 < 5

  2. 11 == 4 ** 2 or 6 != True or not "a" + "b" == "ab"

For each expression below, give in its type and value. The first one is done for you.

  1. True or False

    Type: bool

    Value: True

  2. True and False or True

    Type:

    Value:

  3. 2**3.0

    Type:

    Value:

  4. not 1 + 5 // 2 == 3 and 4 < 5 or 4 != 5

    Type:

    Value: