Flow of Control in Python Class 11 CBSE Computer Science: Introduction, Indentation and Sequential Flow
Class 11 · Computer Science
Flow of Control in Python (CBSE Class 11 Computer Science)
Every Python program consists of multiple statements. The order in which these statements are executed is called the Flow of Control. By default, Python executes statements one after another from top to bottom. Understanding the flow of control is essential before learning decision-making and looping statements.
Learning Objectives
- Understand Flow of Control.
- Learn Sequential Flow.
- Understand Indentation.
- Learn Python Code Blocks.
- Trace Program Execution.
Quick Syntax Reference
| Concept | Purpose |
|---|---|
| Indentation | Defines code blocks |
| Sequential Flow | Statements execute one after another |
| Code Block | Group of statements with the same indentation |
What is Flow of Control?
Flow of Control refers to the order in which the statements of a program are executed.
Program Execution Flow
Program Starts
↓
Statement 1
↓
Statement 2
↓
Statement 3
↓
Program Ends
Sequential Flow
By default, Python executes statements sequentially, that is, one after another in the order they appear.
Example
print("Step 1")
print("Step 2")
print("Step 3")
Output
Step 1
Step 2
Step 3
Dry Run Table
| Step | Statement Executed | Output |
|---|---|---|
| 1 | print("Step 1") | Step 1 |
| 2 | print("Step 2") | Step 2 |
| 3 | print("Step 3") | Step 3 |
Indentation in Python
Unlike many programming languages that use braces ({ }) to group statements, Python uses indentation to define blocks of code.
Example
age = 18
if age >= 18:
print("Eligible")
The indented print() statement belongs to the if block.
Incorrect Indentation
age = 18
if age >= 18:
print("Eligible")
Error
IndentationError
Why Indentation is Important
- Improves readability.
- Defines program blocks.
- Avoids syntax errors.
- Makes programs easier to understand.
Code Block
A Code Block is a group of statements having the same indentation level.
marks = 90
if marks >= 33:
print("Pass")
print("Congratulations")
Both print() statements belong to the same code block.
Trace the Program
x = 5
print(x)
x = x + 3
print(x)
| Step | Statement | Value of x | Output |
|---|---|---|---|
| 1 | x = 5 | 5 | - |
| 2 | print(x) | 5 | 5 |
| 3 | x = x + 3 | 8 | - |
| 4 | print(x) | 8 | 8 |
Think Like a Programmer
Predict the output.
a = 10
b = 20
print(a)
print(b)
print(a + b)
Click to View Answer
10
20
30
Output Prediction Challenge
x = 7
print(x)
x = x * 2
print(x)
x = x - 4
print(x)
Click to View Answer
7
14
10
Real-Life Example
Imagine following a recipe while cooking. You perform each step one after another in the correct order. Similarly, Python executes program statements sequentially unless instructed otherwise.
Common Beginner Mistakes
- Incorrect indentation.
- Mixing tabs and spaces.
- Assuming Python uses braces instead of indentation.
- Writing statements outside the intended block.
Visual Memory Box
- Sequential Flow → Top to Bottom
- Indentation → Defines Code Blocks
- Same Indentation → Same Block
- Wrong Indentation → IndentationError
Memory Trick
S I C
- S → Sequential Execution
- I → Indentation
- C → Code Blocks
Exam Tips
- Remember that Python uses indentation instead of braces.
- Know the meaning of sequential flow.
- Practice tracing simple programs.
CBSE Important Questions
2 Marks
- What is Flow of Control?
- Why is indentation important in Python?
3 Marks
- Explain sequential flow with an example.
- What is a code block?
5 Marks
- Explain Flow of Control, Sequential Flow, and Indentation with suitable examples.
Practice Yourself
- Write a program showing sequential execution.
- Write a program containing two code blocks.
- Identify indentation errors in a given program.
- Trace the execution of a simple Python program.
- Explain why indentation is compulsory in Python.
Frequently Asked Questions (FAQs)
1. What is Flow of Control?
The sequence in which Python executes statements.
2. What is sequential flow?
Execution of statements from top to bottom.
3. Why is indentation required?
It defines blocks of code in Python.
4. What happens if indentation is incorrect?
Python raises an IndentationError.
5. Does Python use braces?
No. Python uses indentation instead of braces.
Summary
- Flow of Control determines the order of program execution.
- Sequential flow executes statements from top to bottom.
- Indentation defines code blocks in Python.
- Incorrect indentation results in an
IndentationError. - Understanding flow of control is the foundation for learning conditional and iterative statements.