By the end of this module you can do everything below. The objectives and their wording come from the official PCEP-30-03 syllabus.
2.1.1 Control program flow using if and if-else statements
- Use an
ifstatement to execute code when a condition is true. - Use an
if-elsestructure to select between two execution paths. - Construct conditions using Boolean expressions.
- Trace which branch is executed based on the result of a condition.
- Recognize when a conditional block is skipped.
2.1.2 Select among multiple execution paths using if-elif-else statements
- Use an
if-elifstructure to evaluate multiple conditions. - Use an
if-elif-elsestructure to provide a fallback execution path. - Explain that conditions are evaluated in order until a matching branch is found.
- Trace the execution of multi-branch conditional structures.
- Recognize incorrectly ordered, redundant, or unreachable conditional branches.
2.1.3 Construct compound and nested conditional structures
- Use multiple conditional statements within the same program.
- Nest conditional statements inside other conditional branches.
- Combine Boolean expressions within conditional structures.
- Trace the execution of compound conditional structures.
- Identify unreachable, redundant, or incorrectly ordered conditional branches.