Skip to main content

Section 4.10 Evaluate Conditionals WE5-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.10.1

Exercises Exercises

1.
Use this given setup for each of the questions below.
alpha = 2
beta = 1
delta = 3
eta = 0
gamma = 0
2.
Q12: After executing the following code, the value in variable gamma is and the value in variable eta is .
if alpha < delta:
    gamma = alpha + 5
else:
    gamma = beta + 5
eta = beta + 2
3.
Q13: After executing the following code, the value in variable gamma is and the value in variable eta is .
if alpha > beta:
    eta = alpha + 2
    gamma = alpha + 5
else:
    eta = alpha - 1
    gamma = beta - 1
You have attempted 1 of 5 activities on this page.