CSC 1301 - Chapter 5: Loops

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

1/23

flashcard set

Earn XP

Description and Tags

Vocabulary practice flashcards covering while loops, for loops, range, nested loops, break, continue, loop else, and enumerate constructs in Python.

24 Terms

1
New cards

Loop

A program construct that repeatedly executes a sequence of statements (known as the loop body) while a controlling expression evaluates to true.

2
New cards

Loop body

The indented block of statements within a loop that executes repeatedly during each cycle as long as the loop condition remains true.

3
New cards

Iteration

A single execution of the statements contained within a loop's body.

4
New cards

While loop

A statement construct that repeatedly executes its body of sub-statements as long as its loop expression evaluates to True, terminating once the condition evaluates to False.

5
New cards

Sentinel value

A specific input value used to signal the end of data entry and terminate a loop's execution.

6
New cards

Infinite loop

A loop that never ceases execution because its controlling condition always evaluates to True.

7
New cards

Euclid's algorithm

An algorithm that computes the greatest common divisor (GCD) of two integers by continually subtracting the smaller value from the larger until both values are equal.

8
New cards

Docstring

A multi-line string literal delimited at the beginning and end by triple quotes (single or double) used to describe and document code.

9
New cards

Loop variable

A variable that is systematically updated during each iteration of a loop to count iterations or control loop execution.

10
New cards

Factorial (N!N!)

The mathematical product of all positive integers less than or equal to NN, defined as N!=N×(N−1)×(N−2)×...×1N! = N \times (N - 1) \times (N - 2) \times \text{...} \times 1.

11
New cards

For loop

A statement that iterates through each element of a container or sequence one at a time, assigning the element to a loop variable for each cycle.

12
New cards

Dictionary iteration

The process of looping through a dictionary with a for loop, which assigns the loop variable to each key of the dictionary in the order of insertion.

13
New cards

reversed()

A built-in function that reverses the order of elements in a sequence, allowing a for loop to iterate backward from the last element to the first.

14
New cards

range()

A built-in function that generates an arithmetic sequence of integers between an inclusive starting integer, an exclusive ending integer, and an optional step value.

15
New cards

Range object

An immutable sequence type representing an arithmetic progression of integers, commonly created by calling the range() function for use in for loops.

16
New cards

Nested loop

A loop construct placed entirely within the body of another loop, commonly referred to as an outer loop and an inner loop.

17
New cards

ord() and chr()

Built-in conversion functions where ord() returns the ASCII/Unicode encoded integer of a character (e.g., 'a' to 9797) and chr() converts an encoded integer back into a character.

18
New cards

Incremental programming

A development practice where a programmer starts with a simple working version of a program and adds features little by little to simplify debugging.

19
New cards

FIXME comment

A standardized comment placed within source code to attract attention to sections that are incomplete or require future modification.

20
New cards

break statement

A control statement inside a loop body that causes immediate termination and exit from the enclosing loop.

21
New cards

continue statement

A control statement inside a loop that causes execution to jump immediately to the loop header for the next iteration.

22
New cards

Loop else construct

An optional clause in a while or for loop that executes once only if the loop completes normally without encountering a break statement.

23
New cards

enumerate()

A built-in function that yields a tuple containing the position index and corresponding element value at each step of sequence iteration.

24
New cards

Unpacking

A process that performs multiple assignments simultaneously by binding comma-separated variable names on the left to elements of a sequence on the right.