Unit 5 Flashcards

1
Q

5.2 - Loops (General)

What is a loop?

A

a programming construct that allows us to repeat lines of code indefinitely

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

5.2 - Loops (General)

What is a loop body?

A

statements/lines of code executed within the loop

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

5.2 - Loops (General)

When are looping conditions evaluated?

When does the loop decide to repeat itself (based on a condition)?

A

after every full execution of the loop

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

5.3 - While Loops

What is a while loop?

A

the loop body executes while a condition is true

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

5.3 - While Loops

What is a sentinel-controlled loop ?

A

a while loop whose condition depends on a specific string/character value*

also called a sentinel value , which changes as the loop progresses

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

5.3 - While Loops

What is an infinite loop?

A

a loop with no termination condition

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

5.4 - More While Loop Examples

What is a docstring?

A

a multi-line comment that describes what the program does prior to execution

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

5.4 - More While Loop Examples

What is a flag-controlled loop?

A

a loop whose execution is determined by a Boolean value

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

5.4 - More While Loop Examples

What is an EOF-controlled loop?

A

a loop determined by “end of file” files

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

5.5 - Counting

How do you make a loop repeat a select number of times?

use i as loop variable, repeat 3 times, assume i = 0

A

while i < 3
i = i + 1 or i += 1

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

5.7 - For Loops

What is a for loop?

A

a loop where a variable is assigned a value each iteration

used for lists, dictionaries, and tuples

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

5.7 - For Loops

What does reversed() do?

A

reverses the order which elements are read through

ex. list = [1, 2, 3]
reversed(list) = [3, 2, 1]

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

5.8 - Counting Using the Range Function

What does range() do?

A

generates a sequence of integers between a starting (inclusive) and ending integer (exclusive)

some ranges feature a third option (integer step value) that changes the rate which numbers are counted
ex. range(0, 11, 2) counts every 2 numbers 0-10

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

Software Development Cycle

What is the Software Development Cycle?

A
  1. identify/state the problem
  2. analyze the problem
  3. design an algorithm to solve the problem
  4. impliment the algorithm via a computer program
  5. test/verify the program
  6. maintain and update the program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly