Skip to main content

Section 16.12 Review - Conditionals

Practice evaluating conditions, determining which branch runs, and writing basic decision-making code.

Subsection 16.12.1 Part A: True or False

Subsection 16.12.2 Part B: Which Branch Runs?

Checkpoint 16.12.2.

State what will be printed.
age = 16
if age >= 18:
    print("Adult")
else:
    print("Minor")

Checkpoint 16.12.3.

State what will be printed.
score = 82
if score >= 90:
    print("A")
elif score >= 80:
    print("B")
else:
    print("Needs Improvement")

Subsection 16.12.3 Part C: Trace the Decision

Checkpoint 16.12.4.

temp = 72
if temp > 75:
    print("Hot")
else:
    print("Not hot")
Complete a table with the condition checked, the result of the condition, the branch that runs, and the output.

Subsection 16.12.4 Part D: Fix

Checkpoint 16.12.5.

The code below has an error. Update it so it runs correctly.

Checkpoint 16.12.6.

The code below has an error. Update it so it runs correctly.

Subsection 16.12.5 Part E: Create

Checkpoint 16.12.7.

Write an if/else statement that prints β€œEven” if a number is even and β€œOdd” otherwise, using num = 7.

Subsection 16.12.6 Think About ...

Checkpoint 16.12.8.

When should a programmer use if/else instead of just writing one print statement?
You have attempted of activities on this page.