Chapter 2 - Iteration Flashcards

1
Q

What is iteration?

A

A procedure or set of commands that are repeated either a set number of times or while a condition is met.

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

What is definite iteration?

A

This is when the number of loops is known before the loop is started, e.g. a for loop

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

What is Indefinite iteration?

A

This is when a number of loops is not known before the loop is started

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

Give an example of definite iteration

A

for i in range(s):
print(‘Hello!’)

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

Give an example of indefinite iteration

A

a = 3
while a < 10:
print(‘a is currently: ‘ + a)
a += 1

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

Is a for loop definite or indefinite iteration

A

definite

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

is a while loop definite or indefinite iteration

A

indefinite

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

is a do…. until loop definite or indefinite iteration

A

indefinite

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

The condition-check in an indefinite iteration loop can contain several layers of what?

A

boolean logic

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

how may a programmer create a script?

A
  1. come up with an idea or be given a brief by a company
  2. sketch out a plan of the script using a list algorithm or flow diagram
  3. Convert plan to pseudo code
  4. write the script
  5. perform a dry run using a trace table
  6. test and analyse results
  7. improve code and repeat step 6
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is a syntax error

A

an error in the code cause by a spelling mistake, grammatical mistake or indentation error etc.

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

what is a logical error

A

the code does work but not as intended

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

what is a dry run

A

the script is run on paper and each stage is carefully analysed to see what values the various variables and outputs have

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

what is a trace table

A

the table that keeps track of the variables and outputs during a dry run

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