Binary & logic
Binary place values (right to left): 1, 2, 4, 8, 16, 32… n bits store 2ⁿ values. x = x × 3 means “take x, triple it, store it back.”
and needs both sides true; or needs at least one. Accuracy = right ÷ total. Halving a list each guess (binary search) takes about log₂(n) guesses.
One step
Binary, variables and logic.Binary
Convert binary 10110 to a normal number. Write 25 in binary.
Trace it
x = 7, then x = x × 3, then x = x − 4. What is x at the end?
True or False
score = 8 and lives = 2. Is score ≥ 10 or lives > 1 True? What if the or is an and?
Bits
How many different values can 4 bits store? 10 bits?
Two or three steps
Trace the code line by line.Loop sum
A loop adds 1 + 2 + … + 200. What is the total? for i in range(5, 15) runs how many times, and what do its i values add up to?
Chance
What is the chance two dice add to 7? That 3 coin flips are all heads?
Lazy filter
200 emails; 20 are spam. A filter that never says “spam” is how accurate? A better one catches 18 spam but flags 6 good emails. How accurate is it?
Average trap
App load times: 4, 6, 6, 8 and 31 seconds. Find the mean and median. Which describes a typical load better?
Move the sprite
A Scratch sprite is at (−120, 60). It changes x by 50 and y by −90. Where is it now?
Guess my number
Binary search halves the range each guess. How many guesses at most for 1 to 500? For 1 to 1,000,000?
Equations
A1–A2 (pp.17–18).One sprite
A sprite starts at x = −180 and moves 12 steps a frame: x = −180 + 12t. On which frame does it reach x = 120?
Two sprites
Sprite B starts at x = 200 and moves −7 a frame: x = 200 − 7t. When and where do the sprites meet?
Jump
A jump follows y = −t² + 12t. When does it land? How high is the top? When is it at height 20?
Pairs
Comparing every pair of n items takes n(n − 1) ÷ 2 checks. If it took 66 checks, find n. How many checks for 20 items?
Your turn to be the game programmer
- Pick a game or app you use.
- Write a question about its bits, loops, chances or coordinates.
- Solve it, then trace it line by line like a computer would.
My problem, and my worked answer:
Try every problem first, then check here. Wrong answers are useful: find the step where your work and the key split apart.
The key never prints with Print my work or Print blank. Open it to get its own Print the answer key button.
Answer key
Worked solutions. Emails and load times are made-up examples.