Repitition Structures Flashcards
What is a repetition structure? aka?
Repetition structure controls a statement or a group of statements to execute repeatedly. A.k.a loop
Cons of not using repetition structure?
long program
time consuming
hard to change
What are the two types of repetition structures?
condition controlled
count controlled
What is condition controlled?
uses true/false condition to loop for a specific amount of time
What is count controlled loop?
loops for a specific amount of times
Condition controlled used using?
while
Count controlled using what?
for
Syntax for while
while y<2:
statement
The while loop is what type of loop
pretest
Infinite loops
continues to repeat until the program is interrupted.
What is a sentinel?
A special value that marks the end of a sequence of values.
Why should you take care to choose a distinctive values as a sentinel?
So that it won’t be mistaken as a regular value in the sequence.
What is input validation?
It is the process of inspecting data that has been input to the program to make sure it is valid before it is used in the computation.
An input validation loop is also known as ?
error handler or error trap
What is priming read? What is its purpose?
the first input before loop.
to get the first input that will be tested by the validation loop