Python, Concept by Concept › Checkpoint 02: Loops

Questions: Checkpoint 02: Loops

Complete all seven questions. Questions 1–2 recap decisions and arithmetic. Questions 3–7 assess loop counters, a computed sentinel with break, a running total, count by condition, and nested table building. Use only the fixed given values and produce the exact output shown.

Each question ends with a Real version note showing how the program can read its values with input().

Question 1: Ordered Battery Ladder

A rover assigns a battery label using the first threshold that matches.

Specification: Given charge, use exactly one if/elif/elif/else ladder. Check charge >= 80 for Full first, charge >= 50 for Ready next, and charge >= 20 for Low next; otherwise print Recharge.

Worked sample — given values:

charge = 67

Expected output:

Ready

Real program

The real program reads a battery charge on one line with input().

How this is checked: Checked by comparing what your program prints with the expected output.

Answer format: one line

Also check yourself

The automatic check cannot see these, so tick each one when your work does it.

For parents and teachers: report a problem

Question 2: Cartons and Leftovers

A supply room packs pencils into full cartons and records the pencils left over.

Specification: Given the non-negative integers pencils and carton_size, use // to calculate full cartons and % to calculate leftovers. Print exactly <cartons> cartons, <leftovers> left.

Worked sample — given values:

pencils = 137
carton_size = 12

Expected output:

11 cartons, 5 left

Real program

The real program reads a pencil count and a carton size on separate lines with input().

How this is checked: Checked by comparing what your program prints with the expected output.

Answer format: one line

Also check yourself

The automatic check cannot see these, so tick each one when your work does it.

For parents and teachers: report a problem

Question 3: While-Counter Pass Bar

A practice robot must finish a fixed number of laps. This is a pass-bar question: the final count must come from a terminating while loop.

Specification: Given the positive integer lap_goal, start laps at 0. Use while laps < lap_goal: and update laps with laps = laps + 1. After the loop, print exactly Count: <laps>.

Worked sample — given values:

lap_goal = 9

Expected output:

Count: 9

Real program

The real program reads a lap goal on one line with input().

How this is checked: Checked by comparing what your program prints with the expected output.

Answer format: one line

Also check yourself

The automatic check cannot see these, so tick each one when your work does it.

For parents and teachers: report a problem

Question 4: Collatz Repeat-Until

A positive number repeats the Collatz rule until a computed stop value appears: divide an even value by 2; otherwise multiply it by 3 and add 1.

Specification: Given n = 9, set steps to 0. Use while True:. First test whether n == 1 and break when it is. Otherwise apply the Collatz rule and add 1 to steps. After the loop, print exactly Steps: <steps>. The given start value is guaranteed to reach 1.

Worked sample — given values:

n = 9

Expected output:

Steps: 19

Real program

The real program reads a starting number on one line with input().

How this is checked: Checked by comparing what your program prints with the expected output.

Answer format: one line

Also check yourself

The automatic check cannot see these, so tick each one when your work does it.

For parents and teachers: report a problem

Question 5: For-Total Pass Bar

A reading challenge awards every whole-number point value from 1 through a final day. This is a pass-bar question: use for, range, and a running total.

Specification: Given the positive integer last_day, start total at 0. Use for day in range(1, last_day + 1): and add each day to total. After the loop, print exactly Sum: <total>.

Worked sample — given values:

last_day = 20

Expected output:

Sum: 210

Real program

The real program reads a last day number on one line with input().

How this is checked: Checked by comparing what your program prints with the expected output.

Answer format: one line

Also check yourself

The automatic check cannot see these, so tick each one when your work does it.

For parents and teachers: report a problem

Question 6: Count by Condition

A game awards a token on round numbers divisible by 7. The organizer needs the number of tokens awarded in the first 50 rounds.

Specification: Use for round_number in range(1, 51):. Add 1 to count only when round_number % 7 == 0. After the loop, print exactly Count: <count>.

Worked sample — required interval:

1 through 50

Expected output:

Count: 7

Real program

The real program reads the last round number on one line with input().

How this is checked: Checked by comparing what your program prints with the expected output.

Answer format: one line

Also check yourself

The automatic check cannot see these, so tick each one when your work does it.

For parents and teachers: report a problem

Question 7: Six-by-Six Times Table

A study sheet needs a multiplication table with six complete rows. Each row must be accumulated as a string before it is printed.

Specification: Given table_size = 6, use nested for loops with outer variable row and inner variable col, each visiting 1 through table_size. Start row_text as an empty string for each outer pass. Accumulate the products with exactly one space between them. Print row_text once after the inner loop.

Worked sample — given values:

table_size = 6

Expected output:

1 2 3 4 5 6
2 4 6 8 10 12
3 6 9 12 15 18
4 8 12 16 20 24
5 10 15 20 25 30
6 12 18 24 30 36

Real program

The real program reads a table size on one line with input().

How this is checked: Checked by comparing what your program prints with the expected output.

Answer format: several lines

Also check yourself

The automatic check cannot see these, so tick each one when your work does it.

For parents and teachers: report a problem

Back to Checkpoint 02: Loops