Skip to main content

Section 3.6 Evaluate Conditionals-WE3-P1

Subgoals for Evaluating Selection Statements.

  1. Diagram which statements go together by indentation
  2. For conditional, determine whether expression is true
    1. If true, follow true branch
    1. If false, follow next elif/else branch or exit conditional if no else branch
  3. Repeat step 2 as necessary

Subsection 3.6.1 Conditionals-WE3-P1

Each question below is independent, but they all use this given setup
a = 1
b = 0
c = 5

Exercises Exercises

1.
    Q12: What is the only numerical value that has a truthiness of False?
  • 1
  • 0
  • No numerical values have a truthiness of False
  • All numerical values have a truthiness of False
2.
3.
Q14: Enter the value of each variable after the following code is executed:
if a + c:
    c = 12
    if c - a:
            a = 1
if b:
    a = b
elif a - a:
    a = c
else:
    a = 13
The value of variable a is , the value of variable b is , and the value of variable c is .
4.
Q15: What is the output of the following code?
if b >= c:
    if b >= a:
        print("b")
    elif a >= c:
        print("a")
elif b >= a:
    print("c")
elif a >= c:
    print("a")
else:
    print("c")
5.
Q16: What is the output of the following code?
if c == 2*a:
    print("double")
elif c == 3*a:
    print("triple")
elif c == 4*a:
    print("quadruple")
elif c == 5*a:
    print("quintuple")
else:
    print("unknown")
You have attempted of activities on this page.