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:
Ask the student to communicate to a partner or the class what will be the outcome of this code.
Ask the following questions:
- 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 alter the code to create a different 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:
How can the code be altered in order to sort and classify the numbers as either even or odd?