๐ Computational Thinking & Programming-I Quiz 7 โ Flow of Control (Class 11 CS)
Practice 20 CBSE Class 11 Computer Science (Code 083) MCQs on the flow of control โ indentation, sequential flow, conditional flow (if/elif/else), iterative flow (for/while loops), loop control keywords (break, continue, pass), range(), and nested structures.
Every code behaviour below has been verified by actually running it in Python. Tap any question to reveal the answer with a clear explanation.
๐ Flow of Control
What does flow of control refer to in programming?
- The order in which statements are written in the program
- The direction in which data flows through the program
- The decision-making process in the program
- The flow of execution through the program
Show Answer & Explanation
โ Answer: (d) The flow of execution through the program
Flow of control refers to the order in which statements are actually executed โ which can differ from how they’re written on the page, once conditions, loops, and function calls come into play.
โฅ Indentation
What is the purpose of indentation in Python?
- To make the code look neat and organized
- To indicate the start and end of a block of code
- To define the structure of the program
- To improve the performance of the program
Show Answer & Explanation
โ Answer: (b) To indicate the start and end of a block of code
In Python, indentation isn’t just a style choice โ it’s syntactically required to mark where a block of code starts and ends (inside an if, for, while, or function). Most other languages use braces { } for this instead.
โก๏ธ Sequential Flow
What is sequential flow of control?
- Execution of statements in a specific order from top to bottom
- Execution of statements based on a condition
- Repetitive execution of statements until a condition is met
- Execution of statements in a random order
Show Answer & Explanation
โ Answer: (a) Execution of statements in a specific order from top to bottom
Sequential flow is the simplest and default flow โ statements run one after another, top to bottom, in exactly the order they’re written, with no branching or repetition.
โ Conditional Flow
Which control structure is used for making decisions in programming?
- Looping
- Indentation
- Conditional statements
- Function calls
Show Answer & Explanation
โ Answer: (c) Conditional statements
Conditional statements (if, elif, else) are what let a program branch and make decisions โ running different code depending on whether a condition is true or false.
โ Conditional Flow
What is the purpose of conditional statements?
- To repeat a block of code multiple times
- To control the flow of execution based on a condition
- To improve the readability of the code
- To define the structure of a function
Show Answer & Explanation
โ Answer: (b) To control the flow of execution based on a condition
Conditional statements exist to control which code runs based on whether a condition evaluates to True or False โ letting the program react differently to different situations.
โ Conditional Flow
Which of the following is a conditional statement in Python?
- for loop
- while loop
- if statement
- break statement
Show Answer & Explanation
โ Answer: (c) if statement
The if statement is Python’s core conditional construct. for and while are looping constructs, and break is a loop-control keyword โ neither makes a decision on its own.
๐ Iterative Flow
What is iterative flow of control?
- Execution of statements in a specific order from top to bottom
- Execution of statements based on a condition
- Repetitive execution of statements until a condition is met
- Execution of statements in a random order
Show Answer & Explanation
โ Answer: (c) Repetitive execution of statements until a condition is met
Iterative flow means a block of code runs repeatedly โ either a fixed number of times or until some condition is no longer true โ which is exactly what loops are built for.
๐ Iterative Flow
Which control structure is used for repetitive execution of code in programming?
- Looping
- Indentation
- Conditional statements
- Function calls
Show Answer & Explanation
โ Answer: (a) Looping
Looping (using for or while) is the control structure specifically designed to repeat a block of code multiple times.
๐ Iterative Flow
What is the purpose of loops in programming?
- To make the code look neat and organized
- To indicate the start and end of a block of code
- To define the structure of the program
- To repeat a block of code multiple times
Show Answer & Explanation
โ Answer: (d) To repeat a block of code multiple times
Loops exist purely to repeat a block of code multiple times โ avoiding the need to manually rewrite the same statements over and over.
๐ Iterative Flow
Which of the following is an iterative control structure in Python?
- if statement
- for loop
- break statement
- function call
Show Answer & Explanation
โ Answer: (b) for loop
The for loop is one of Python’s two core iterative structures (the other being while) โ it repeats a block of code once for each item in a sequence.
โ Conditional Flow
Which keyword is used to test additional conditions after an initial if, without writing a separate nested if?
- else
- elif
- and
- break
Show Answer & Explanation
โ Answer: (b) elif
elif (short for โelse ifโ) lets you chain multiple condition checks in a single, flat if-elif-else structure, instead of nesting a new if inside every else.
๐ Iterative Flow
Which loop is typically used when the number of iterations is known in advance?
- while loop
- for loop
- if-else statement
- try-except block
Show Answer & Explanation
โ Answer: (b) for loop
A for loop is the natural choice when you already know how many times to repeat โ e.g. iterating over a list or a fixed range().
๐ Iterative Flow
Which loop is typically used when the number of iterations depends on a condition and isn’t known in advance?
- for loop
- while loop
- if-else statement
- function call
Show Answer & Explanation
โ Answer: (b) while loop
A while loop keeps running as long as its condition stays true โ perfect for situations where you don’t know upfront exactly how many repetitions will be needed.
๐ Loop Control
Which keyword immediately terminates a loop before it has finished all its iterations?
- continue
- pass
- break
- return
Show Answer & Explanation
โ Answer: (c) break
break exits the loop immediately, skipping any remaining iterations entirely, and execution continues with the code right after the loop.
๐ Loop Control
Which keyword skips the rest of the current iteration and moves on to the next one?
- break
- continue
- pass
- exit
Show Answer & Explanation
โ Answer: (b) continue
continue stops the current pass through the loop body right where it is, and jumps straight to the next iteration โ the loop itself keeps running.
๐ Loop Control
Which keyword acts as a null operation โ a placeholder used when Python’s syntax requires a statement but you want no action to happen?
- break
- continue
- pass
- none
Show Answer & Explanation
โ Answer: (c) pass
pass does absolutely nothing โ it’s used as a placeholder inside an empty if, loop, or function body so the code remains syntactically valid while you fill in the logic later.
๐ Iterative Flow
What does range(5) generate in Python?
- Numbers from 1 to 5
- Numbers from 0 to 4
- Numbers from 0 to 5
- Numbers from 1 to 4
Show Answer & Explanation
โ Answer: (b) Numbers from 0 to 4
range(5) generates 5 numbers starting from 0, up to (but not including) 5: 0, 1, 2, 3, 4.
โฅ Indentation
What happens if the indentation is inconsistent within the same block of code in Python?
- Python ignores it and runs the code normally
- It raises an IndentationError
- It automatically fixes the indentation
- It only causes a warning, not an error
Show Answer & Explanation
โ Answer: (b) It raises an IndentationError
Since Python relies on indentation to define blocks, mixing inconsistent spacing within the same block raises an IndentationError and stops the program from running.
๐ Iterative Flow
In Python, can a for loop or while loop have an else block, and what does it do?
- No, loops cannot have an else block
- Yes, and it always runs after every loop, no matter what
- Yes, and it runs only if the loop completes without hitting a break
- Yes, but it only works with while loops, not for loops
Show Answer & Explanation
โ Answer: (c) Yes, and it runs only if the loop completes without hitting a break
Python uniquely allows an else block after a loop โ it runs only if the loop finishes naturally without being stopped early by a break. If a break does occur, the else block is skipped entirely.
โ Conditional Flow
What is a nested conditional or nested loop?
- Two independent loops running one after another
- A conditional statement or loop placed inside another conditional statement or loop
- A loop that runs only once
- An error that occurs when loops are used incorrectly
Show Answer & Explanation
โ Answer: (b) A conditional statement or loop placed inside another conditional statement or loop
Nesting means placing one control structure inside another โ like an if inside a for loop, or a loop inside another loop โ to handle more complex, layered logic.
