C3.2 Read and alter existing code, including code that involves sequential, concurrent, repeating, and nested events, and describe how changes to the code affect the outcomes.

Activity 1: Nested Events (Counting in Fractional Intervals)


  • Ask students to read the code below and describe what the code is doing.
Image Blocks of code: Events block stating “start on when green flag clicked.” Variables block stating “set day to ‘0’.” Control block stating “repeat 10. Inside 1 nested blocks. Control block stating “repeats 3”. Inside are 2 nested blocks. Variable block stating “change day by ‘1’”. Looks block stating “say join day ‘one third’ for ‘1’ seconds”.
  • Discuss with students the outcome of the code.
  • Ask students the following questions:
    • What is happening with the loop inside another loop?
    • How can the code be altered to count in half increments? in quarter increments? in sixth increments?
    • How will these changes impact the outcome?

Activity 2: Repetitive and Nested Events (Link to Time)


  • Ask students to read the code below and describe what the code is doing.
Image Blocks of code: Events block stating “start on when green flag clicked.” Variables block stating “set day to ‘0’.” Variables block stating “set week to ‘0’.” Control block stating ”repeat ‘2’.” Inside 1 nested blocks. Control block stating ”repeat ‘2’.” Variables block stating “set day to ‘0’.” Looks block stating “say ‘Monday’.” Variables block stating “change day by ‘1’.” Control block stating “wait ‘1’ seconds.” Variables block stating “set day to ‘0’.” Looks block stating “say ‘Tuesday’.” Variables block stating “change day by ‘1’.” Control block stating “wait ‘1’ seconds.” Variables block stating “set day to ‘0’.” Looks block stating “say ‘Wednesday’.” Variables block stating “change day by ‘1’.” Control block stating “wait ‘1’ seconds.” Variables block stating “set day to ‘0’.” Looks block stating “say ‘Thursday’.” Variables block stating “change day by ‘1’.” Control block stating “wait ‘1’ seconds.” Variables block stating “set day to ‘0’.” Looks block stating “say ‘Friday’.” Variables block stating “change day by ‘1’.” Control block stating “wait ‘1’ seconds.” Variables block stating “set day to ‘0’.” Looks block stating “say ‘Saturday’.” Variables block stating “change day by ‘1’.” Control block stating “wait ‘1’ seconds.” Variables block stating “set day to ‘0’.” Looks block stating “say ‘Sunday.” Variables block stating “change day by ‘1’.” Variables block stating “Change week by ‘1’.” Control block stating “wait ‘1’ seconds.” Looks block stating “say ‘7 days in one week!’.” Control block stating “wait 3 seconds.” Looks block stating “say ‘4 weeks in one month!’”.
  • Ask students the following questions:
    • How will the outcome be impacted if the control block Blocks of code: Control block stating “repeat 2”. is changed to Blocks of code: Control block stating “repeat 2”.? Explain.
    • How can the code be altered to represent months and a year? years and a decade? decades and a century?