Chapter 5 (Loops) Flashcards

1
Q

One set of instructions that operate on multiple, separate sets of data

A

Loop

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

This keyword starts the loop body and precedes any statements that execute when the tested condition is True.

A

While

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

What keyword ends the “while” loop structure?

A

Endwhile

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

What does the loop control variable do?

A

Manages the number of repetitions a loop performs.

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

What are the 3 actions that should occur when using a loop control variable:

A
  1. INITIALIZE the variable before entering the loop.
  2. TEST the variable to see if the result is True, before entering the loop.
  3. Set conditions which allow the variable to be ALTERed within the body of the loop.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the significance of making the loop control variable alterable within the body of the loop?

A

It allows the tested condition to return as false, which will make the loop end (eventually).

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

Initializing the loop control variable is essentially providing the loop with a ______ ____.

A

starting value

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

The 3 separate actions concerning a loop control variable prevents ______ _____.

A

infinite loops

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

What are 2 common loop control variable types?

A
  1. a counter

2. a sentinel value

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

Sentinel values as a loop control variable are used to create what type of loop?

A

indefinite

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

These loops execute a predetermined number of times.

A

Definite loops

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

A counter is any numeric value that counts the number of times an event has occurred. What is the best number to start a counted loop at?

A

0

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

This naturally lends itself to definite loops with a starting value/counter of 0

A

array manipulation

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

Is starting a counter loop at 0 necessary?

A

No, but it is encouraged.

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

Counted loops are a program that track the number of loop repetitions by counting them. What is another name for counted loops?

A

Counter-controlled loops.

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

These loops perform a varying amount of times.

A

Indefinite loops

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

<> is a ______ symbol

A

placeholder

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

What is the name of this placeholder symbol: <>

A

Not-equal-to-operator

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

Evaluates as True when its operands are not equivalent/identical

A

<>

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

What are loops within loops?

A

Nested loops

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

The nested loop contains:

A

At least 1 outer loop, and at least 1 inner loop

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

An inner loop goes through all of its iterations each time that an outer loop goes through how many iterations?

A

One

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q
# of inner loop iterations * # of outer loop iterations
The above is...
A

the formula for the total number of iterations executed by a nested loop.

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

Another phrase for the “for statement”

A

For loop

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

For statements are used for what type of loop?

A

Definite loops

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

What is the keyword that ends for statements?

27
Q

Step value is…

A

the amount by which a for loop control variable changes.

28
Q

The step value can be any number. If the step value is positive or negative this implies ______ or ______ a value.

A

incrementing, decrementing

29
Q

The for loop provides a convenient shorthand for what type of loop?

A

a While loop

30
Q

What allows a for loop to be a shorthand version of a while loop?

A

They are both used for definite loops where the loop control variable progresses from a known starting value to a known ending value IN EQUAL STEPS.

31
Q

Which loop is particularly useful for processing arrays?

32
Q

What does the expression count++ do in a for loop?

A

It increases count by 1.

33
Q

The loop control variable is tested before each iteration in a…

A

Pretest loop

34
Q

What is the significance of a pretest loop?

A

It allows it so that a loop body might never execute, because the evaluation controlling the loop might be false the first time it is made.

35
Q

The loop body executes at least once in this type of loop

A

Posttest loop

36
Q

In a posttest loop, the loop control variable is not tested until after the 1st ______

A

iteration.

37
Q

What is another name for the posttest loop?

A

do while loop

38
Q

In a do while loop, the action you “do” _______ testing the condition.

39
Q

a ______ followed by a pretest while loop is the equivalent of a do while loop.

40
Q

What is the significance of these two characteristics?

  1. The loop-controlling evaluation must provide either the entry to or exit from the structure.
  2. The loop-controlling evaluation provides the ONLY entry to or exit from the structure
A

These are the characteristics all structured loops (both pretest and posttest) have in common.

41
Q

A variable used to gather values, similar to a counter that you use to count loop iterations

A

Accumulator

42
Q

What are the 3 actions that must be taken with an accumulator?

A
  1. INITIALIZE it to 0
  2. ALTER the accumulator for every dataset processed
  3. OUTPUT the accumulator’s value at the end of all processing.
43
Q

The accumulator variable is most often altered by using _______.

44
Q

Variables only exist during an _________ of the program.

45
Q

These contain only totals, and have no data for individual records.

A

Summary reports

46
Q

Programming that tries to prepare for all possible errors before they occur.

A

Defensive programming

47
Q

What is the function that a loop performs when used to make sure that data is meaningful, useful, is the correct data type, or falls within an acceptable range?

A

Validate data

48
Q

GIGO stands for

A

“Garbage in, garbage out”

49
Q

What does GIGO mean?

A

If your input is incorrect, your output is worthless.

50
Q

Forcing a data item means you ________ incorrect data by setting the variable to a specific, predetermined value.

51
Q

Using the module’s results without understanding its internal statements means employing a…

A

Black box variable

52
Q

What are 3 methods used to ensure data is valid?

A
  1. DISPLAY error message
  2. CHOOSE A DEFAULT VALUE before proceeding to the next step with a garbage input.
  3. REPROMPT the user for valid input.
53
Q

In the ________ ________, the two logical paths that emerge from testing the condition join together following their actions.

A

selection structure

54
Q

In a ____ _______, the paths that emerge from a tested condition do not joint together.

A

Loop structure

55
Q

One of the logical branches that emerges from the _______-_________ _______ eventually returns to the same test, in a loop structure.

A

structure-controlling decision

56
Q

Selections and loops both begin with a _______ expression and both structures have a body that executes when said expression is evaluated as _____.

A

Boolean; True

57
Q

When nesting loops, you maintain two ________ loop control variables and alter each at the appropriate time.

58
Q

The ___ statement uses a loop control variable that it automatically initializes, tests, and alters.

59
Q

The loop body executes at least one time in a…

A

posttest loop

60
Q

____ count = 0 to 3 step 1
______ “Hello”
______

A

for; output; endfor

61
Q
count = 0
\_\_\_\_\_ count <= 3
     output "Hello"
     count = \_\_\_\_\_\_ + \_\_
\_\_\_\_\_\_\_\_
A

while; count; 1; endwhile

62
Q

the amount by which a loop control variable changes is called a ____ value.

63
Q

for loops and while loops are types of _____ loops.