Skip to main content

Section 3.2 Evaluate Conditionals-WE1-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.2.1 Conditionals-WE1-P1

Each question below is independent, but they all use this given setup
alpha = 2
beta = 1
delta = 3
eta = 0
gamma = 0
omega = 2.5
theta = -1.3
kappa = 3.0

Exercises Exercises

1.
Q1: After executing the following code:
if theta > omega:
    gamma = kappa + 2
The value of variable gamma is
2.
Q2: After executing the following code:
if beta < alpha:
    eta = 42
The value of variable eta is
3.
Q3: After executing the following code:
if kappa < delta:
    eta = 42
beta = 22
the value of variable eta is and the value of variable beta is
4.
Q4: After executing the following code:
if gamma < kappa:
    beta = 22
eta = 42
The value of variable eta is and the value of variable beta is .
5.
6.
You have attempted of activities on this page.