3.2.2 - Programming concepts Flashcards
(10 cards)
What are the three basic programming constructs?
Sequence
Selection
Iteration
Variable
A named memory location that stores a value that can change.
Constant
A value that does not change during program execution.
Selection
Using a condition to control program flow.
if age >= 18:
print(“Adult”)
else:
print(“Child”)
Iteration
Repeating a set of instructions using loops (e.g., FOR, WHILE) until a condition is met.
Count-controlled iteration
for i in range(5): print(i)
Condition-controlled iteration
while not_done: do_task()
Assignment
Setting or updating the value stored in a variable.
Nested iteration
Using one loop inside another loop to repeat code in multiple layers.
Nested selection
A selection statement placed inside another selection statement to make decisions based on multiple conditions.