Variables and Assignment in Text Code · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Names that remember

Computing · Programming · ages 14-15
Name ______________________   Date ____________
  1. How do you show a stored value on screen?

    • Delete the variable
    • Print it back out
    • Rename the file
  2. What does score = 0 do?

    • Stores 0 under the name score
    • Checks if score equals 0
    • Prints 0 to the screen
  3. In score = 0, the value on the right is stored in the name on the left.

    Circle one:   True   False

  4. Which name says what the value means?

    • x
    • q2
    • player_score
  5. After score = 0 then score = 5, what does score hold?

    • 0
    • 5
    • 0 and 5 together
  6. Which line stores text correctly?

    • name = 14
    • name = true
    • name = "Lia"
  7. Writing player = GrayFox with no quotes stores the text GrayFox.

    Circle one:   True   False

  8. Mia runs score = 0, then score = 5, then prints score. A friend says 0 prints. What is wrong?

    • Nothing, 0 prints
    • The old 0 is gone, so 5 prints
    • Print shows the starting value
LightMySky · lightmysky.comW1-mt_uLHLaX8BQq-s1

Answer key

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

Names that remember W1-mt_uLHLaX8BQq-s1

  1. Print it back out · Printing a name shows whatever value it currently holds.
  2. Stores 0 under the name score · The equals sign stores the right side into the name on the left.
  3. True · Assignment flows right to left: value into name.
  4. player_score · Player score describes the value, while single letters hide meaning.
  5. 5 · The second assignment replaces the first, so score holds 5.
  6. name = "Lia" · Text needs quotes, so only the quoted word counts as text. The bare forms are a number and a boolean.
  7. False · Text needs quotes. Without them the code hunts for a variable named GrayFox and errors.
  8. The old 0 is gone, so 5 prints · Reassignment replaces the old value, so the name holds 5 when printed.
Worksheet · LightMySky