The shape of the lesson
By the end of the lesson, learners can
- DIV and MOD: In the lab, choose MOD, DIV and ROUND.
- ROUND: ROUND takes a value (or an expression) and the number of decimal places to round it to.
- RANDOM numbers: RANDOM() returns a real number from 0 to 1.
- DIV(a, b): whole number of times b goes into a.
- MOD(a, b): the remainder left over. Check: DIV × b + MOD = a.
- ROUND(x, n): look at the next decimal place; 5 or more rounds up.
- RANDOM(): 0 to 1; multiply, ROUND to 0 places, then add to set the range.
One picture every idea returns to
A library routine is a pre-written, pre-tested subroutine that comes with a programming language. DIV(a, b) returns the whole-number quotient of a divided by b, with the fractional part discarded. MOD(a, b) returns the remainder. ROUND(x, places) returns x rounded to that number of decimal places. RANDOM() returns a random number between 0 and 1 inclusive.
Forty-five minutes, phase by phase
| Time | Phase | What happens in the room | Grouping |
|---|---|---|---|
| 0 to 5 min | Hook: predict | Open with the question in the title, Ready-made routines.. Programming languages come with routines that are already written and tested, so you do not have to write them yourself. Put the figure on the board: it is the one picture every idea in the lesson returns to. | Whole class, then pairs |
| 5 to 13 min | Teach and check: DIV and MOD | In the lab, choose MOD, DIV and ROUND. Project tab 5 of the lab (Library routines) and let a student drive it while the class predicts. Model the worked example Splitting a number on the board, one line at a time. Your turn: Convert 250 seconds to minutes and seconds using DIV and MOD. | Whole class, then pairs |
| 13 to 21 min | Teach and check: ROUND | ROUND takes a value (or an expression) and the number of decimal places to round it to. Model the worked example Rounding on the board, one line at a time. | Pairs |
| 21 to 30 min | Teach and check: RANDOM numbers | RANDOM() returns a real number from 0 to 1. Model the worked example A different range on the board, one line at a time. | Anticipation / Reaction Guide |
| 30 to 36 min | Check | The four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong. | Individual, then whole class |
| 36 to 43 min | Plenary | The exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording. | Individual, random call |
| 43 to 45 min | Exit and homework | Set the worksheet below (6 questions, 17 marks). Learners self-assess against the objectives before they leave. | Individual |
Protect the parts that carry the learning
The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.
Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.
Cut first if the build overruns: the last check in RANDOM numbers, never the check or the plenary.
In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.
Anticipation / Reaction Guide
Before the lesson, students mark five statements true or false. After the teaching they mark them again and justify any change of mind in one sentence each. The statements come from the examiner traps below.
The full structure, with its variations and the other twelve, is on the cooperative-learning page.
What to head off, and how
| Trap learners fall into | Teaching move that pre-empts it |
|---|---|
| MOD gives the remainder, not the decimal part: MOD(7, 2) is 1, not 0.5. | DIV(7, 2) is 3, not 3.5. |
| ROUND returns a new value; it does not change the variable unless you assign the result back, e.g. | Price ← ROUND(Price, 2). |
| ROUND(RANDOM() * 6, 0) gives 0 to 6, which is seven possible values, not a dice roll. | Check the smallest and largest values of your expression. |
Library routines: MOD, DIV, ROUND and RANDOM: worksheet
6 questions, 17 marks. Written in the style of the papers; no past paper question is reproduced.
State what is returned by the library routines DIV and MOD.
State the value returned by: (a) DIV(29, 4) (b) MOD(29, 4) (c) ROUND(29 / 4, 0) (d) ROUND(12.3456, 2)
Write pseudocode that inputs a number of seconds and outputs it as minutes and seconds, using DIV and MOD.
Write a statement that stores a random whole number from 1 to 100 in the variable Target. Explain why your expression cannot give 0 or 101.
Write pseudocode that inputs a whole number and outputs "Even" or "Odd".
A student tests whether Number is even with IF Number / 2 = 0. Explain why this does not work and correct it.
Answer key and marking notes
- DIV returns the quotient of a division with the fractional part discarded (a whole number).
- MOD returns the remainder of the division.
- (a) 7
- (b) 1
- (c) 29 / 4 = 7.25, which rounds to 7
- (d) 12.35
INPUT SecondsMins ← DIV(Seconds, 60)andSecs ← MOD(Seconds, 60)OUTPUT Mins, " minutes ", Secs, " seconds"
Target ← ROUND(RANDOM() * 99, 0) + 1- ROUND(RANDOM() * 99, 0) gives a whole number from 0 to 99.
- Adding 1 gives 1 to 100, so 0 and 101 are impossible.
INPUT NumberIF MOD(Number, 2) = 0THEN OUTPUT "Even" ELSE OUTPUT "Odd"with ENDIF
- Number / 2 is the result of the division, which is only 0 when Number is 0; it is not the remainder.
- Correct:
IF MOD(Number, 2) = 0.
6 multiple-choice questions on this lesson
From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.
What are the values of DIV(29, 6) and MOD(29, 6)?
- A4 and 5
- B5 and 4
- C4.83 and 5
- D4 and 0.83
What value is returned by ROUND(7.4567, 2)?
- A7.46
- B7.45
- C7.5
- D7.457
RANDOM() returns a random number from 0 to 1 inclusive. Which expression simulates a dice roll, a whole number from 1 to 6?
- A
ROUND(RANDOM() * 5, 0) + 1 - B
ROUND(RANDOM() * 6, 0) - C
ROUND(RANDOM() * 6, 0) + 1 - D
RANDOM() * 6
Seconds holds 500. What is output by OUTPUT DIV(Seconds, 60), " min ", MOD(Seconds, 60), " s"?
- A8 min 20 s
- B8 min 0.33 s
- C8.33 min 20 s
- D20 min 8 s
What is output?
Number ← 4072
Sum ← 0
WHILE Number > 0 DO
Sum ← Sum + MOD(Number, 10)
Number ← DIV(Number, 10)
ENDWHILE
OUTPUT Sum- A13
- B451
- C4
- D2
Which condition is TRUE exactly when Year is divisible by 4 but not divisible by 100?
- A
MOD(Year, 4) = 0 AND MOD(Year, 100) <> 0 - B
MOD(Year, 4) = 0 OR MOD(Year, 100) <> 0 - C
DIV(Year, 4) = 0 AND DIV(Year, 100) <> 0 - D
MOD(Year, 4) <> 0 AND MOD(Year, 100) = 0
Quiz key
6 goes into 29 four whole times (24), leaving 5, so DIV(29, 6) = 4 and MOD(29, 6) = 5. 5 and 4 swaps the two routines. 4.83 is 29 / 6, but DIV discards the fractional part. 0.83 is the decimal part of 29 / 6, not the remainder.
Two decimal places keeps 7.45; the next digit is 6, which is 5 or more, so it rounds up to 7.46. 7.45 just cuts the number off (truncates). 7.5 rounds to one decimal place. 7.457 rounds to three decimal places.
RANDOM() * 5 runs from 0 to 5; rounding gives a whole number 0 to 5, and adding 1 gives 1 to 6. ROUND(RANDOM() * 6, 0) gives 0 to 6, seven values including 0. Adding 1 to that gives 1 to 7. RANDOM() * 6 is not rounded, so it gives values such as 3.72.
60 goes into 500 eight whole times (480) with 20 left over, so the output is 8 min 20 s. 0.33 is the decimal part of 500 / 60, not the remainder. 8.33 is 500 / 60, but DIV gives only the whole-number part. 20 min 8 s swaps the two results.
Each pass adds the last digit and then removes it: 2, then 7, then 0, then 4, giving 2 + 7 + 0 + 4 = 13; then Number is 0 and the loop stops. 451 swaps MOD and DIV (407 + 40 + 4). 4 is the number of passes. 2 is only the first digit added, as if the loop ran once.
MOD(Year, 4) = 0 means divisible by 4, and MOD(Year, 100) <> 0 means not divisible by 100; both must hold, so AND is needed (2024 TRUE, 1900 FALSE). With OR, 2023 is accepted because it is not divisible by 100. DIV gives the quotient, not the remainder, so DIV(Year, 4) = 0 is FALSE for every year from 4 upwards. The last option reverses both tests.
What to project
The student lesson embeds these tabs. Open them full screen on the projector; every slider has a drag handle on the stage.
Slides for this lesson
A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.