Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1Value ← ROUND(RANDOM() * 6, 0) | AFUNCTION RollDie() RETURNS INTEGER RETURN ROUND(RANDOM() * 5, 0) + 1 ENDFUNCTION | |
| 2Roll ← ROUND(RANDOM() * 5, 0) + 1 | BROUND(RANDOM() * 10, 0) | |
| 3Nesting one routine inside another: RANDOM() is called inside ROUND() to get a whole number | CStores a random whole number from 0 to 6 in the variable Value | |
| 4A function that returns a die roll from 1 to 6 | DStores a random whole number from 1 to 6, like a die roll | |
| 5Value ← ROUND(RANDOM(), 0) * 6 | EThis gives 1 to 7, not 1 to 6, because the range 0 to 6 has 7 values and adding 1 shifts it to 7. To roll a die, multiply by 5 instead: ROUND(RANDOM() * 5, 0) + 1. | |
| 6Roll ← ROUND(RANDOM() * 6, 0) + 1 | FROUND is applied before multiplying. RANDOM() is a decimal from 0 to 1, so it rounds to only 0 or 1, giving just 0 or 6. The multiplication should be inside ROUND: ROUND(RANDOM() * 6, 0). |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
ROUND(RANDOM() * 6, 0) — Gives a random whole number from 0 to 6. RANDOM() gives a decimal from 0 to 1, times 6 stretches it, and ROUND(..., 0) turns it into a whole number.Value ← ROUND(RANDOM() * 6, 0)// random whole number 0 to 10
Value ← ROUND(RANDOM() * 10, 0)// random whole number 1 to 6
Value ← ROUND(RANDOM() * 5, 0) + 1FUNCTION RollDie() RETURNS INTEGER
RETURN ROUND(RANDOM() * 5, 0) + 1
ENDFUNCTIONValue ← ROUND(RANDOM() * 6, 0)