Skip to content
Exit presentation

Programming with Blocks II

Track quiz

Use the table if you get stuck.

Programming with Blocks II: the five ideas
IdeaRemember
A named boxA variable is a named box. It holds one value at a time. Setting it replaces what was there.
Changing itAn add block reads the number in the box. It works out the new number. It writes that back.
WaitingAn event block names one happening. Its group runs only when that happening comes.
Nested blocksNesting puts one block inside another. The outside block decides whether, and how often, the inside runs.
Planning firstA plan puts each step after the step it needs.

A box named lives holds 3. A block sets it to 1. Another sets it to 5. What is in the box?

  • 3, 1 and 5 together
  • 5, and nothing else
  • 9, because the box adds every number

A box is named mangoes and holds 400. What does the name tell the computer about mangoes?

  • That the box counts fruit
  • Nothing. It only tells blocks which box to use
  • That the number can never change

A box holds 4. The block add 1 to score runs twice. What is in the box now?

  • 5
  • 6
  • 4 and 5 and 6

score is 0. Repeat 4 times: add 3. What does score hold at the end?

  • 3
  • 12
  • 7

score = score + 1 looks wrong in Maths. Why is it fine in a program?

  • The computer ignores the plus sign
  • It is an order: read the box, then write the new number
  • Programs do not follow Maths

Four groups wait. A tap happens. One group names a tap. What runs?

  • Only that group
  • All four groups
  • No group, until every event happens

A game does nothing between taps. What does that tell you?

  • The program has crashed
  • Its groups are waiting for their events
  • The tap block is broken

score starts at 1. A: if score < 3, repeat 3 times, add 1. B: repeat 3 times, if score < 3, add 1. Where do they finish?

  • Both at 3
  • A at 4, B at 3
  • Both at 4

A plan lists show the score before set the score to 0. Why is that a problem?

  • The box may still hold an old number
  • The two steps do the same job
  • Plans must be in alphabet order

You can now keep a number and change it. You can run a group on an event. You can read one block inside another.

Next comes Data & Patterns II. It starts with one switch, on or off.

Jump to lesson

This track

  1. 0 Start here
  2. 1 A box with a name on it
  3. 2 Changing what is in the box
  4. 3 Waiting for something to happen
  5. 4 One block inside another
  6. 5 Plan it before you build it
  7. 6 The big picture
  8. 7 Track quiz

Other tracks