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 explain their understanding of it.
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 results of the code.
  • Ask students the following questions:
    • Why is there a loop inside another loop?
    • Is it possible to change the code to count in half increments? in quarter increments? in sixth increments? What needs to be changed?
    • Can you describe the impact of the changes on the outcome?

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


  • Ask students to read the code below and explain their understanding of it.
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:
    • What would be the impact on the outcome if the control block Blocks of code: Control block stating “repeat 2”. were changed to Blocks of code: Control block stating “repeat 2”.?
    • Explains the impact of this change on the results.
    • Is it possible to modify the code to represent months and a year? years and a decade? decades and a century?