Chapter 2 Flashcards
Define iteration
A procedure that is repeated a set number of times or until a condition is met
Define definite iteration
Where the number of iterations is known before the loop begins
Define indefinite iteration
Where the number of iterations are not known before the loop begins.
Keeps looping until a condition is met.
Which type of iteration?
for i in range(5):
print(‘Hello’)
Definite
Which type of iteration?
While a < 10:
print(a)
a +=1
Indefinite
What is a nested loop?
A loop inside another loop
Example of a nested loop:
for table in range(1,13,1):
for times in range(1,13,1):
print(‘table’ +’x’+ ‘table’ +’=’+ table*times)
Define syntax error
Errors when writing the script. E.g. Spelling mistake, grammar or indentation error.
Define logical error
The code runs, but not as intended
What is a dry run?
The script is run on paper and each stage is carefully analyzed to see what values the variables and outputs have.
What is a trace table?
A table that keeps track of the variables and outputs.
What are dry runs good for?
Finding logical errors.