Free Online Flashcard Deck

4 Control Flow and Logic Free Online FlashCards

Study 4 Control Flow and Logic with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is a sequence in program control flow?

Back

A sequence executes instructions in order, from top to bottom, once each.

02
Front

What does a conditional do?

Back

A conditional selects which statements execute based on whether a Boolean condition is true or false.

03
Front

How does Python choose among if and elif branches?

Back

Only the first branch whose condition is true runs. If no condition is true, the else branch runs, when present.

04
Front

What is the difference between = and ==?

Back

= assigns a value, whereas == tests whether two values are equal.

05
Front

What do Python’s and, or, and not operators do?

Back

and is true only when both expressions are true; or is true when at least one is true; not reverses a Boolean value.

06
Front

What is short-circuit evaluation?

Back

Short-circuit evaluation stops when the final result is already known. For example, and can avoid division if its first condition is false.

07
Front

When is a for loop commonly used?

Back

Use a for loop to process each item in a sequence or iterate through a known range of values.

08
Front

Which values does range(1, 5) produce?

Back

range(1, 5) produces 1, 2, 3, and 4; its ending value, 5, is excluded.

09
Front

What is an accumulator in a loop?

Back

An accumulator stores a running result that is updated during each loop iteration, such as a sum, count, or product.

10
Front

How does a while loop control repetition?

Back

A while loop repeats as long as its condition remains true. The condition is tested before each iteration.

11
Front

What is the difference between break and continue?

Back

break immediately ends the nearest loop, while continue skips the rest of the current iteration and starts the next one.

12
Front

What is a nested control structure?

Back

A nested structure places one control structure inside another, such as an if statement inside a loop.