Module 4 Flashcards

1
Q

While loop

A

Executes instructions repeatedly while a condition is true.

while CONDITION :
STATEMENTS

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

count-controlled vs. event controlled

A

count controlled (aka definite) is used more-so as a counter and can be used a definite number of times, where as event controlled (indefinite) executes until an event occurs

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

typical outline of a while loop

A

Update the loop variable

# Check the loop variable ( while ____ <= n)
# Update the loop variable ( VARIABLE +1)
# Print results

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

When does a while loop not display an output?

A

When the loop is false, or when the loop runs forever

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

What is an off-by-one error?

A

A common error when programming loops. Think through simple test cases to avoid this type of error.

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

named argument

A

end= “”
by adding this as the last argument to the first print function, we indicate that an empty string is to be printed after the first argument is displayed. The output of the next print function starts on the same line where the previous one left off.

Example:

print(“00”, end=” “)
print(3+4)

output: 007

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

sentinel value

A

denotes the end of a data set, but it is not part of the data

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

priming read

A

the input operation before the loop, because it prepares or initializes the loop variable

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

modification read

A

the input operation at the bottom of the loop is used to obtain the next input. It modifies the loop variable inside the loop.

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