The code you've provided primarily demonstrates Iteration. Let's break it down:
-
Iteration: The part of the code that iterates over the
colourList
using aFOR
loop is the primary example of iteration. This allows the program to repeat a block of code (in this case, printing each colour) for each item in the list. -
Sequencing: This refers to the order in which the statements are executed. The program first prints the message "The rainbow colours are: " and then starts to iterate through the list. This linear execution of statements is an example of sequencing.
-
Selection: This construct is not explicitly used in your code. Selection usually refers to decision-making structures like
if
statements that allow a program to execute certain blocks of code based on conditions. Since your example doesn't include any conditional statements, selection is not represented here.
So, in summary:
- The provided code demonstrates Iteration (through the
FOR
loop), and it includes Sequencing (the order of execution of statements), but does not include Selection.