Question
WHILE (timer > 0):
PRINT "Carry on playing..."
timer = timer - 1
This code uses:
SelectionIterationSequencing
PRINT "Carry on playing..."
timer = timer - 1
This code uses:
SelectionIterationSequencing
Answers
GPT-4o mini
The code you provided demonstrates **iteration**. Here's a breakdown of the three basic programming constructs:
1. **Sequence**: This refers to the execution of statements in a linear, step-by-step manner. Each line of code executes one after the other.
2. **Selection**: This involves making decisions in the code, typically using conditional statements (like `if`, `else`, etc.) to execute certain blocks of code based on conditions.
3. **Iteration**: This involves repeating a block of code multiple times, usually with a loop structure (like `while`, `for`, etc.).
The code snippet you provided uses a `while` loop to repeatedly print "Carry on playing..." until the `timer` is no longer greater than 0. Hence, the correct usage in your context is **iteration**.
1. **Sequence**: This refers to the execution of statements in a linear, step-by-step manner. Each line of code executes one after the other.
2. **Selection**: This involves making decisions in the code, typically using conditional statements (like `if`, `else`, etc.) to execute certain blocks of code based on conditions.
3. **Iteration**: This involves repeating a block of code multiple times, usually with a loop structure (like `while`, `for`, etc.).
The code snippet you provided uses a `while` loop to repeatedly print "Carry on playing..." until the `timer` is no longer greater than 0. Hence, the correct usage in your context is **iteration**.