1/20
By the end of this section, students should be able to... • Use if, elif, and else statements to implement conditional logic • Understand how Boolean expressions control flow decisions • Use logical operators (and, or, not) to combine conditions • Write for and while loops to perform repetitive tasks • Use break and continue and pass to control loop execution • Apply nested conditionals and loops in basic algorithmic structure
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Control Flow
The order in which individual instructions are executed in a program.
Sequential Execution
Python’s default mode: executing code line-by-line from top to bottom.
Conditional Logic
A way to make decisions in code using Boolean values and conditional statements.
if Statement
Executes code only if a specified condition is True.
elif Statement
Checks a new condition if previous if or elif blocks did not execute.
else Statement
Executes code if none of the previous conditions were True.
Boolean Expression
An expression that evaluates to True or False; it’s the basis for all decision-making in control flow.
zip()
Tool for pairing up elements from two sequences; stops at the shortest sequence.
enumerate()
A clean and safe way to access both the index and value in a loop, avoiding manual counter variables.
Algorithmic Thinking
Using structured control flow (conditions + loops) to solve problems step-by-step.
Short-Circuit Evaluation
Python stops evaluating logical expressions as soon as the result is known (e.g., in A and B
, if A is False, B isn’t evaluated).
Logical Operators
(and, or, not). Tools for combining Boolean expressions to form more complex conditions.
Decision Branching
The process of selecting which code path to follow based on conditions (like a mental flowchart).
for Loops
Best used when the number of iterations is known or tied to a sequence (like a list or range).
while Loops
Best used when the number of iterations is unknown and depends on a condition being True.
Indefinite vs Definite Loops
for loops are definite (known count); while loops are indefinite (condition-based).
break Loop Control
Used to exit a loop early, regardless of whether the loop condition has been met.
continue Loop Control
Skips the rest of the current iteration and moves to the next loop cycle.
pass Loop Control
A placeholder when syntax requires a block, but no action should occur; helps plan structure without causing errors.
Infinite Loop
A loop that never ends due to a condition that is never updated to False (often a logical bug).
Nested Structures
Loops or conditionals placed inside one another; used for more complex, layered logic.