Random Numbers and Programs That Differ Each Run · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

A new surprise every run

Computing · Computing Fundamentals · ages 12-13
Name ______________________   Date ____________
  1. A dice program should roll 1 to 6. Which range keeps every roll legal?

    • 0 to 9
    • 1 to 6
    • 1 to 100
  2. What is a random value in a program?

    • A value the computer picks fresh on each run
    • A value typed by the player
    • A value that never changes
  3. Two runs of a dice program must show the same number.

    Circle one:   True   False

  4. A game drops a star at a random x from 0 to 400 on a 400-wide screen. One day a star never appears. What is the likely cause?

    • The range reaches the very edge, where the star hides
    • The screen is too wide
    • Stars are afraid of screens
  5. You run a coin-flip program ten times and see heads every time. What should you conclude?

    • The program is proven fair
    • Short runs can look lopsided by chance
    • Coins always land heads
  6. You run the same program three times. What should you write down?

    • What stayed the same and what changed
    • Only the funniest run
    • Nothing, memory is enough
  7. A Treat-or-Trick program shows Trick below 5 and Treat at 5 or above, from 0 to 10. After a thousand runs each word appears about half the time. What does that tell you?

    • The program is broken
    • The words are misspelled
    • The split sits near the middle of the range
  8. A friend says one winning run proves a dice game is correct. What is wrong with that proof?

    • Winning runs do not count
    • One run cannot show the broken values chance never picked
    • Dice games cannot be tested
LightMySky · lightmysky.comW1-mt_t8GTOW3hyN-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

A new surprise every run W1-mt_t8GTOW3hyN-s1

  1. 1 to 6 · The range must match the allowed faces, and only 1 to 6 does that.
  2. A value the computer picks fresh on each run · Random means newly picked each run, inside the range you set.
  3. False · Random picks fresh each run, so the two numbers often differ.
  4. The range reaches the very edge, where the star hides · A value at the extreme edge can park the star out of sight.
  5. Short runs can look lopsided by chance · Ten runs are too few, since chance alone can stack one side.
  6. What stayed the same and what changed · Comparing steady code against changing values shows what randomness controls.
  7. The split sits near the middle of the range · Many runs even out, and a middle split gives each word about half the runs.
  8. One run cannot show the broken values chance never picked · A single run samples one value, leaving illegal edges untested.
Worksheet · LightMySky