Chapter 5: Iteration

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

1/29

flashcard set

Earn XP

Description and Tags

Flashcards covering key concepts from Chapter 5 on Iteration, including updating variables, while statements, loop patterns, and debugging.

Last updated 7:32 PM on 6/10/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

30 Terms

1
New cards

Updating Variables

A common pattern in assignment statements where the new value depends on the old, such as x = x + 1. Requires initialization before updating.

2
New cards

Increment

Updating a variable by adding 1.

3
New cards

Decrement

Updating a variable by subtracting 1.

4
New cards

While Statement

A Python language feature for iteration that repeats a block of code as long as a condition is true.

5
New cards

Iteration

Each execution of the body of a loop.

6
New cards

Iteration Variable

The variable that changes each time the loop executes and controls when the loop finishes.

7
New cards

Infinite Loop

A loop that repeats forever because there is no iteration variable or the terminating condition is never satisfied.

8
New cards

Break Statement

A statement used to jump out of a loop, typically used in infinite loops when an exit condition is met.

9
New cards

Continue Statement

A statement used to skip the current iteration of a loop and jump to the next iteration.

10
New cards

Definite Loop (For Loop)

A loop that iterates through a known set of items, such as a list of words, lines in a file, or a list of numbers.

11
New cards

Indefinite Loop (While Loop)

A loop that continues until some condition becomes False.

12
New cards

Loop Patterns

Common structures for looping through items to find something, like the largest or smallest value.

13
New cards

Counting Loop

A loop that counts the number of items in a list.

14
New cards

Summing Loop

A loop that computes the total of a set of numbers.

15
New cards

Accumulator

A variable used in a loop to add up or accumulate a result.

16
New cards

Maximum/Minimum Loops

Loops designed to find the largest or smallest value in a list or sequence.

17
New cards

None

A special constant value in Python used to mark a variable as 'empty'.

18
New cards

Debugging by Bisection

A debugging technique where you break the program in half to isolate the source of an error.

19
New cards

Counter

A variable used in a loop to count the number of times something happened, initialized to zero and incremented each time.

20
New cards

Initialize

Assigning an initial value to a variable before it is updated in a program.

21
New cards

Infinite loop info

How to avoid : make sure loop control variable is in header (ie while i<= 10: - i is loop ctrl variable , if its not in he header it will continue to infinity)

22
New cards

While loop using boolean operators

poop=0

while not poop xxx: (this means while poop is true cuz poop variable is defined as false) (0 means false)

23
New cards

i

i is a common LOOP CONTROL VARIABLE

24
New cards

How to choose which loop to use

• When you know the number of iterations

 use a counter-controlled or definite loop such as “for”

• When the iterations depend on a condition

 use a conditional or indefinite loop such as “while”

25
New cards

Is and Is not operators

‘Is’ operator means ‘is the same as’

‘Is not’

26
New cards

How to know what itertion variable to use and when

When you know how many times you want the thing to = for

when you want something to keep going UNTIL something happens = while

27
New cards

ranges

range(stop) - goes from 0 , stops 1 before the stop

range(start,stop) - goes from start to 1 before stop

range(start,stop,+- step)- goes from start to 1 before stop , increases/decreases by step each time

28
New cards

odd/even .py

  • Add +1 at the end of the range to make python iterate the full range number , not just stop one before

  • to see is something is even - n %2 (returns a remainder)== 0 obvi if its even theres no remainder

29
New cards

constants

variable name in all caps , BIG_FORHEAD = 5 ; Python recognizes this as a constant.

30
New cards

Break vs continue

Continue - means if x== 5 , pass by ie dont use this , like ignore it and go to the next one

break , if x==5 , stop executing the loop entirely.