Chapter 4: Repetition Structures

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/28

flashcard set

Earn XP

Description and Tags

Comprehensive vocabulary flashcards defining key terminology, loop types, control statements, and logic mechanisms from Chapter 4 (Repetition Structures).

29 Terms

1
New cards

Repetition structure

A programming structure that makes the computer repeat included code as necessary, avoiding the need to duplicate code.

2
New cards

Condition-controlled loop

A category of loop that uses a true/false condition to control the number of times it iterates.

3
New cards

Count-controlled loop

A category of loop that repeats a specific number of times.

4
New cards

while loop

A condition-controlled loop that repeats statements as long as a tested condition evaluates to true.

5
New cards

Iteration

One execution of the body of a loop.

6
New cards

Pretest loop

A loop that tests its condition before performing an iteration; it will never execute if the condition is false to begin with.

7
New cards

Infinite loop

A loop that lacks a mechanism to stop and continues executing until the program is interrupted.

8
New cards

Counter variable

A variable assigned a unique value during each iteration of a loop, used to count the number of times the loop iterates.

9
New cards

Initialization (count-controlled loop)

The action of setting the counter variable to a suitable starting value before the loop begins.

10
New cards

Comparison (count-controlled loop)

The action of evaluating the counter variable against a suitable ending value to determine whether the loop should iterate.

11
New cards

Update (count-controlled loop)

The action performed during each loop iteration that modifies the counter variable with a new value.

12
New cards

Single-line while loop

A while loop written entirely on one line when there is only one statement in its body.

13
New cards

for loop

A Python statement designed to write a count-controlled loop that iterates once for each item in a sequence of data items.

14
New cards

Target variable

The variable in a for loop that is the target of assignment at the beginning of each iteration.

15
New cards

Iterable

An object that contains a sequence of values that can be iterated over, such as the object returned by the range function.

16
New cards

range function

A built-in function that simplifies writing a for loop by generating an iterable sequence of integer values.

17
New cards

Step value

The optional third argument in the range function that specifies the increment or decrement between each consecutive value in the sequence.

18
New cards

Running total

A cumulative sum of a series of numbers that is accumulated across iterations of a loop.

19
New cards

Accumulator

A variable used in a program to store and accumulate numbers, referencing the total sum at the end of the loop.

20
New cards

Augmented assignment operators

Special shorthand operators (such as +=, -=, *=, /=, and %=) designed for assignment statements where the variable on the left of the = operator also appears on the right side.

21
New cards

Sentinel

A distinctive value that marks the end of a sequence of items, signaling the program to terminate the loop.

22
New cards

GIGO

An acronym standing for 'garbage in, garbage out,' meaning that if a user inputs bad data, the program will produce bad output.

23
New cards

Input validation

The process of inspecting data before it is processed by a program to ensure invalid or bad input is rejected.

24
New cards

Walrus operator

The assignment expression operator (:=) that allows combining a priming read with an input validation loop header.

25
New cards

Nested loop

A loop that is placed inside the body of another loop.

26
New cards

Total iterations of a nested loop

The total number of loop cycles calculated by number of iterations of inner loop×number of iterations of outer loop\text{number of iterations of inner loop} \times \text{number of iterations of outer loop}.

27
New cards

break statement

A statement that immediately causes a loop to terminate execution.

28
New cards

continue statement

A statement that ends the current iteration early, causing the loop to skip the remainder of its body and move to the next iteration.

29
New cards

else clause (with loops)

An optional block that executes after a while or for loop terminates normally, but does not execute if the loop is exited via a break statement.