AME 209: 15. Control Flow

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/20

flashcard set

Earn XP

Description and Tags

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

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

21 Terms

1
New cards

Control Flow

The order in which individual instructions are executed in a program.

2
New cards

Sequential Execution

Python’s default mode: executing code line-by-line from top to bottom.

3
New cards

Conditional Logic

A way to make decisions in code using Boolean values and conditional statements.

4
New cards

if Statement

Executes code only if a specified condition is True.

5
New cards

elif Statement

Checks a new condition if previous if or elif blocks did not execute.

6
New cards

else Statement

Executes code if none of the previous conditions were True.

7
New cards

Boolean Expression

An expression that evaluates to True or False; it’s the basis for all decision-making in control flow.

8
New cards

zip()

Tool for pairing up elements from two sequences; stops at the shortest sequence.

9
New cards

enumerate()

A clean and safe way to access both the index and value in a loop, avoiding manual counter variables.

10
New cards

Algorithmic Thinking

Using structured control flow (conditions + loops) to solve problems step-by-step.

11
New cards

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).

12
New cards

Logical Operators

(and, or, not). Tools for combining Boolean expressions to form more complex conditions.

13
New cards

Decision Branching

The process of selecting which code path to follow based on conditions (like a mental flowchart).

14
New cards

for Loops

Best used when the number of iterations is known or tied to a sequence (like a list or range).

15
New cards

while Loops

Best used when the number of iterations is unknown and depends on a condition being True.

16
New cards

Indefinite vs Definite Loops

for loops are definite (known count); while loops are indefinite (condition-based).

17
New cards

break Loop Control

Used to exit a loop early, regardless of whether the loop condition has been met.

18
New cards

continue Loop Control

Skips the rest of the current iteration and moves to the next loop cycle.

19
New cards

pass Loop Control

A placeholder when syntax requires a block, but no action should occur; helps plan structure without causing errors.

20
New cards

Infinite Loop

A loop that never ends due to a condition that is never updated to False (often a logical bug).

21
New cards

Nested Structures

Loops or conditionals placed inside one another; used for more complex, layered logic.