Loops and Loop Control Flashcards
Enumerate the 3 Loop Types
- While Loop
- For Loop
- Nested Loop
Enumerate the 3 Loop Controls
- Break Statement
- Continue Statement
- Pass Statement
It is a sequence of instructions that is repeated continuously until a certain phase is reached.
Loop
It is a basic programming concept that is widely used in writing programs.
Loops
It allows multiple execution of a statement or a group of statements.
Loop statement
It is used to iterate over a block of code as long as the test expression (condition) is true. It tests the condition before executing the loop body.
While loop
is used to iterate a sequence (list, tuple, string) or other iterable objects.
For loop
Iteration over a sequence is called
Traversal
allows one loop to be used inside another loop
Nested Loops
It change the execution of the loop from its normal sequence.
Loop control statements
Terminates the loop statement and transfers execution to the statement immediately following the loop.
Break statement
Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. It returns the control to the beginning of the while loop.
Continue statement
is used when a statement is required syntactically but you do not want any command or code to execute. It is used when a statement is required syntactically but you do not want any command or code to execute.
Pass statement