Week 5: Loops Flashcards

(13 cards)

1
Q

Loop Concept

A

Driving around the block until your baby falls asleep.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Loop

A

A loop is just like a branch but the loop jumps back to the top and will continue to iterate while the loop’s expression is true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

While Loop

A

This kind of loop is used when you don’t know how many iterations you need to do. The loop will continue to run as long as the conditions are true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

For Loop

A

Use these when you know how many iterations you need the loop to make.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Counting with a While Loop

A

You can update each iteration of your loop until the loop condition is false. (+=, *=, or /=)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

For Loop

reversed()

A

This function makes the for loop iterate BACKWARDS starting with the last element and ending with the first.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

for Loop

range()

A

This function allow for counting in for loops as well.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Nested Loops

A

Is a loop that appear as part of the body of another loop. You can call then outer loops and inner loops

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Incremental Programming

A

Is a way to minimize debugging. Start with a simple version of your program and grow it little by little into the complete version.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Break statements

A

A break statement in a loop causes the loop to exit immediately. Used to make a loop easier to understand.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Continue Statements

A

A continue statement in a loop causes an immediate jump the while OR for loop header statement. Used to improve readability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Loop Else

A

A loop can include an else clause that executes ONLY if the loop terminates normally and doesn’t use a break statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

enumerate()

A

This function retrieves BOTH the index and its corresponding element value at the same time. Used to make things clean and readable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly