Practice with puzzles instead of plain quizzes. Put code in order, find the bug, build a query, match terms and sort cards. Earn points, stars and badges, keep a streak going, and read a full explanation after every puzzle.
You’ll practice: Variables, lists, for loops and indentation
This program should print the average of three test scores, but its lines are jumbled. Tap the lines in the order Python should run them. Tap a placed line to send it back.
How it works
scores = [78, 92, 85] creates a list holding the three scores.
total = 0 starts a running total. It has to exist before the loop adds to it.
for s in scores: visits each score in turn, so the loop body runs three times.
total += s is indented, which puts it inside the loop. After the loop, total is 78 + 92 + 85 = 255.
average = total / len(scores) runs once, after the loop. len(scores) is 3, so the average is 85.0.
print(average) shows 85.0.
Why the order matters: if the average line were indented inside the loop, Python would recalculate it on every pass. That still ends at 85.0 here, but it does extra work and can hide bugs in longer programs.
You’ll practice: Reading code, range() and off-by-one errors
This program should count the even numbers from 1 to 10 and print 5, but it prints 4. Tap the line that contains the bug.
How it works
The bug is on line 2: range(1, 10) produces 1 to 9, so the loop never sees 10. The even numbers it finds are 2, 4, 6 and 8, which makes 4.
The fix:for n in range(1, 11):. Now the loop includes 10 and the program prints 5.
This is called an off-by-one error, one of the most common bugs in programming. Whenever a loop has a start and a stop, check both ends: is the first value included, and is the last one?
Write a query that lists the names of employees in department 10, sorted alphabetically. Tap a keyword to fill the next blank. Tap a filled blank to clear it. Some keywords aren’t needed.
How it works
The finished query is SELECT name FROM employees WHERE dept_id = 10 ORDER BY name;
SELECT chooses the columns to return, here just name.
FROM names the table the rows come from.
WHERE keeps only the rows that match a condition, department 10.
ORDER BY sorts the result, alphabetically by default.
The unused keywords: GROUP BY combines rows for totals such as COUNT(*), HAVING filters those groups, and JOIN combines two tables. None of them is needed for a simple filtered list.
You’ll practice: Double-entry bookkeeping and the debit and credit rules
A bakery records three transactions, and each one touches two accounts. Tap a card, then tap Debit or Credit for the account named on it. Tap a placed card to move it back.
How it works
Customer pays cash: debit Cash (an asset goes up) and credit Sales Revenue (revenue goes up).
Rent paid in cash: debit Rent Expense (an expense goes up) and credit Cash (an asset goes down).
Oven bought on credit: debit Equipment (an asset goes up) and credit Accounts Payable (a liability goes up).
Every transaction has equal debits and credits, which is why the books always balance: assets = liabilities + equity.