Chapter 2 Flashcards

1
Q

Define iteration

A

A procedure that is repeated a set number of times or until a condition is met

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

Define definite iteration

A

Where the number of iterations is known before the loop begins

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

Define indefinite iteration

A

Where the number of iterations are not known before the loop begins.
Keeps looping until a condition is met.

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

Which type of iteration?
for i in range(5):
print(‘Hello’)

A

Definite

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

Which type of iteration?
While a < 10:
print(a)
a +=1

A

Indefinite

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

What is a nested loop?

A

A loop inside another loop

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

Example of a nested loop:

A

for table in range(1,13,1):
for times in range(1,13,1):
print(‘table’ +’x’+ ‘table’ +’=’+ table*times)

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

Define syntax error

A

Errors when writing the script. E.g. Spelling mistake, grammar or indentation error.

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

Define logical error

A

The code runs, but not as intended

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

What is a dry run?

A

The script is run on paper and each stage is carefully analyzed to see what values the variables and outputs have.

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

What is a trace table?

A

A table that keeps track of the variables and outputs.

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

What are dry runs good for?

A

Finding logical errors.

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