C3.2 Read and alter existing code, including code that involves sequential and concurrent events, and describe how changes to the code affect the outcomes.
Activity 1: Repeating Patterns and Number Patterns
Ask students to read the following code:
![Drum set.](/img/activite/algebre/2e/VE2_Algebre_Image169.png)
![](/img/activite/algebre/2e/en/VE2_Algebre_Image170_en.png)
![A saxophone.](/img/activite/algebre/2e/VE2_Algebre_Image171.png)
![5 blocks as follows:Events block stating, “starts on when the green flag is clicked”.Looks block stating “hide”. Events block stating “wait, ‘two’ seconds.”Looks blocks stating “show”.Sound blocks stating, “play the sound ‘b sax’’’.](/img/activite/algebre/2e/VE2_Algebre_Image172.png)
![A drum set.](/img/activite/algebre/2e/VE2_Algebre_Image169.png)
![](/img/activite/algebre/2e/en/VE2_Algebre_Image173_en.png)
![Saxophone.](/img/activite/algebre/2e/VE2_Algebre_Image171.png)
![5 blocks as follows:Events blocks stating, “starts on when green flag is clicked”.Looks blocks stating “hide”. Controls blocks stating “wait, ‘two’ seconds”.Looks blocks stating “show”.Sounds blocks stating “play the sound ‘b sax’’’.](/img/activite/algebre/2e/en/VE2_Algebre_Image174_en.png)
Ask the student to communicate to a partner or the class what will be the result of this code.
Ask the following questions:
- Is the code a repeated or growing pattern?
- Do you see any patterns?
- What is the pattern?
Ask the student to explain what happens when you change the wait seconds.
Ask the student to modify the code to obtain a growing pattern.
Activity 2: Even and Odd Numbers
Ask the student to read the pseudo-code below:
Each line is displayed simultaneously.
Display the following number: 22
Display : This is an even number.
Display the following number: 3
Display : This is an odd number.
Display the following number: 15
Display : This is an odd number.
Display the following number: 60
Display : This is an even number.
Display the following number: 4
Display : This is an even number.
Display the following number: 17
Display : This is an odd number.
Ask the following question:
Is it possible to modify the code in order to sort and classify the numbers according to the following two classes: even numbers and odd numbers?