Skip to main content

Section 4.14 Evaluation Conditionals-WE6-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 4.14.1

Exercises Exercises

1.
2.
Use this given setup for each of the questions below.
alpha = 2
beta = 1
delta = 3
eta = 0
gamma = 0
omega = 2.5
theta = -1.3
kappa = 3.0
lambda_ = 0.0
rho = 0.0
3.
Q18: After executing the following code, the value in variable eta is .
if omega > kappa:
    if alpha > delta:
        eta = 5
    else:
        eta = 4
else:
    if alpha < delta:
        eta = 3
    else:
        eta = 2
4.
Q19: After executing the following code, the value in variable a is and the value in variable b is .
a = -5
b = 5
if a < 0:
    if b > 0:
        a = b
else:
    a = b + 10
    b = b + 3
5.
Q20: After executing the following code, the value in variable x is and the value in variable y is .
x = -8
y = 10
if x < 0:
    if y < 0:
        x = y
else:
    x = y + 10
    y = x + y
You have attempted 1 of 7 activities on this page.