# Investigation: Repetition with Processing

## While - Loops

Exercise 1: What does the following code do?
How can I increase the number of lines?
How can I decrease the number of lines?
How can I change the program so the lines go all the way from top to bottom?

Exercise 2: What does the following code do?
How could you change the code so the squares are centred?

Exercise 3: What does this code do?
How could we change the code so there are more red rings?
How could we change the code so the red rings are further apart?

Exercise 4: Change the code so:

• if the user hits ’+’, increase the number of circles drawn.
• if the user hits ‘-’, decrease the number of circles drawn.

The picture should appear as the following:

## For-Loops

Exercise 5: What does this code do?
How can I change the code so the houses are further apart?
How can I change the code so the houses are closer together?

Exercise 6: What does this code do?
How can I change the code so the circles are shades of red?
How can I change the code so the circles are stacked in the opposite direction (i.e. largest at the bottom, smallest at the top)?

Exercise 7: Write a program that draws alternating blue and yellow rows using for-loops. Given the following pre-defined variables:

• screen_size = 200
• total_rows = 10
• row_height = screen_size / total_rows