COMPUTER Flashcards
What is control flow in a program?
The order in which the program’s code executes.
What regulates the control flow of a Python program?
Conditional statements, loops, and function calls.
What are the three types of control structures in Python?
- Sequential
- Selection
- Repetition
What are sequential statements?
A set of statements whose execution happens in a sequence.
What happens if there is a logic error in sequential statements?
The complete source code execution will break.
What are selection statements also known as?
Decision control statements or branching statements.
What do selection statements allow a program to do?
Test several conditions and execute instructions based on which condition is true.
What is the purpose of an IF statement?
To run a particular code only when a certain condition is met.
What does an IF-ELSE statement do?
Executes the body of if if the test condition is True; otherwise, executes the body of else.
What is the function of an IF-ELIF-ELSE statement?
To conditionally execute a statement or a block of statements.
What is a repetition statement used for?
To repeat a group (block) of programming instructions.
What are the two types of loops in Python?
- For loop
- While loop
What is the purpose of a FOR loop?
To iterate over a sequence such as a list, tuple, dictionary, or set.
What is the syntax of a Python FOR loop?
for iterating_var in sequence: statement(s)
What does the WHILE loop do?
Repeatedly executes a target statement as long as the specified boolean expression is true.
What is the syntax of a while loop?
while expression: statement(s)
What indicates the start of an indented block in a loop?
A colon (:) at the end of the loop header.
What happens when the boolean expression in a while loop becomes false?
The program control passes to the line immediately following the loop.
What is an infinite loop?
A loop that continues to run and doesn’t stop unless forcefully stopped.
True or False: A while loop can only execute once.
False
Fill in the blank: A _______ statement is used to repeat a group of programming instructions.
repetition