Control Structures: One Mark Questions, Book Back Answers and Notes
Control structures decide the order in which Python runs statements. This chapter covers the three kinds: sequential statements, branching with if, if-else and if-elif-else, and looping with while and for. It also explains the jump statements break, continue and pass, and how Python uses indentation to mark a block.
Study this chapter
Asked in previous board exams
7 questions from this chapter came in 6 past public exams. Open any of them to see the answer and explanation.
-
March 2025
Which of the following is known as definite loop?See answer in the solved paper →
-
March 2024
Pick the correct one to execute the given statement successfully.See answer in the solved paper →
if ________ : print(x, "is a leap year") -
March 2024
What is the output of the following snippet in Python ?See answer in the solved paper →
for x in range (5):
if x==2:
continue
print(x, end=' ') -
March 2023
The number of important control structures in Python :See answer in the solved paper →
-
May 2022
'elif' can be considered to be short form of __________.See answer in the solved paper →
-
Supplementary 2021
What plays a vital role in Python programming ?See answer in the solved paper →
-
March 2020
What is the output of the following snippet ?See answer in the solved paper →
for i in range(2,10,2):
print(i,end=' ')
About Control Structures
Medium ~120 min study
By default a program runs sequentially: the first statement, then the second, then the third, from top to bottom. Real programs cannot work that way all the time. A billing program must give a discount only if the amount crosses a limit. A marks program must repeat the same calculation for every student. A control structure is a statement that changes this normal top-to-bottom flow.
Python groups control structures into three types: sequential, alternative (branching) and iterative (looping). Branching statements test a condition that gives True or False and pick one path. Looping statements repeat a block while a condition holds or once for each item in a sequence. C++ and Java mark blocks with curly braces. Python uses indentation instead, so the spaces at the start of a line are part of the syntax, not decoration.
Many questions from this chapter give you a short piece of code and ask for its output: how many times a loop runs, what range() generates, what happens after break or continue, and whether a loop's else block runs. Trace every loop on paper, one iteration at a time, and these questions become routine.
What you'll learn
- Explain sequential flow and say when a program needs branching or looping instead.
- Write programs using if, if-else and if-elif-else, including the one-line conditional form.
- Write while and for loops, and state exactly which values range() produces for given arguments.
- Predict the output of loops that contain break or continue.
- Use pass as a placeholder in an empty block or function.
- Indent blocks correctly and spot indentation errors in given code.
Before you start
- Basic Python syntax: variables, data types, input() and print().
- Relational operators such as == and != and logical operators and, or, not.
- Strings as sequences of characters with index positions.
Topics covered in this chapter
Control Structures explained
How Python Decides What Runs Next
Control Flow and Indentation
A control structure makes control jump from one part of the program to another, depending on the state of the program at that moment. In Python, a block and its sub-blocks are marked only by indentation, using spaces or tabs. Every statement in the same block must start at the same column. Four spaces per level is the usual practice. If one line in a block is shifted by even a single space, the interpreter raises an IndentationError, or the line silently moves into a different block and the logic changes.
Branching Statements
Branching statements test a relational or logical expression and choose a path based on whether it is True or False. Python gives three forms. The simple if runs a block only when the condition is true. if-else chooses between two blocks. if-elif-else checks several conditions in order and runs the block of the first one that is true; the else part runs only if none of them match. Every header line ends with a colon. For a simple two-way assignment Python also allows a one-line form: x = 10 if a > b else 20.
Loops: while and for
A loop repeats a block of statements. The while loop is entry-controlled: it checks the condition first and runs the body only while the condition is true, so if the condition is false at the start the body never runs. The for loop goes through the items of a sequence such as a string, a list or the numbers produced by range(). range(start, stop, step) starts from start (default 0), moves by step (default 1) and stops before reaching stop. So range(1, 10, 2) gives 1, 3, 5, 7, 9. Both loops can have an optional else block, which runs once when the loop ends normally, that is, when the condition becomes false or all items have been used.
Jump Statements: break, continue and pass
A jump statement transfers control without testing a condition. break ends the loop at once and control goes to the first statement after the loop; the loop's else block is skipped. continue skips only the rest of the current iteration and goes back to the loop header for the next one. pass is a null statement: it does nothing when executed. Use it where Python needs a statement for the syntax to be valid, such as an empty loop, if block or function that you plan to fill in later.
Common mistakes to avoid
- Writing if a = 5: instead of if a == 5:. A single = is assignment, and Python gives a SyntaxError when it is used as a condition in an if or while header.
- Leaving out the colon at the end of an if, elif, else, while or for header.
- Indenting lines of the same block by different amounts, or mixing tabs and spaces, which causes an IndentationError or TabError.
- Assuming range(1, 5) includes 5. It gives 1, 2, 3, 4; with a positive step the stop value is never reached.
- Expecting a loop's else block to run after break. It runs only when the loop finishes normally.
Test yourself on these with the practice test, then check the worked reasoning in the solved MCQs.
Frequently asked questions
What is the difference between break and continue?
break ends the whole loop and control moves to the statement after the loop. continue ends only the current iteration: the remaining statements in the body are skipped and the loop goes on with the next value or the next condition check.
Does the else block of a loop run if the loop ends with break?
No. The else block runs only when the loop ends normally, when a while condition becomes false or a for loop has used every item. If break stops the loop, the else block is skipped and control goes to the statement after the loop.
How does range() work in a for loop?
range(start, stop, step) produces integers beginning at start and changing by step each time, stopping before stop. If you give one argument, start is 0 and step is 1, so range(5) gives 0, 1, 2, 3, 4. range(10, 0, -2) counts down: 10, 8, 6, 4, 2.
Why is indentation so strict in Python?
Python has no curly braces to mark blocks, so indentation is the only way it knows which statements belong inside an if, loop or function. All statements of one block must have the same indentation. Inconsistent spacing gives an error or quietly moves a statement into the wrong block.
What is the difference between entry-check and exit-check loops?
An entry-check loop tests the condition before running the body, so the body may not run even once. An exit-check loop tests the condition after the body, so the body always runs at least once. Python's while and for loops are both entry-check loops.
What is the use of the pass statement?
pass is a null statement; nothing happens when it runs. Python does not allow an empty block, so pass is written inside an if, loop, function or class that has no code yet. It keeps the program syntactically valid until you add the real statements.
How do you write if-else in one line in Python?
Use the form variable = value1 if condition else value2. For example, big = a if a > b else b stores a in big when a is greater than b, and b otherwise. This form suits simple two-way assignments; longer logic should use the normal if-else block.
Last updated 15 September 2026