Page 490 - ComputerScience_Class_11
P. 490
iNtroductioN to PytHoN
flow of coNtrol
Learning Objectives
12.1 Introduction to Programming Construct 12.2 Indentation in Python
12.3 Types of Flow of Control
Flow of control refers to the order in which individual statements, instructions or function calls are executed in a
program. Understanding flow of control is key to creating logical structures in software, allowing for decision-making,
looping and branching, thus enabling dynamic and interactive program behaviour based on conditions.
In this chapter, you will learn about programming construct, flow of control, its types and iterative statements.
12.1 INTRODUCTION TO PROGRAMMING CONSTRUCT
Programming constructs are the basic building blocks used to control the flow of execution in a program. They
determine the order in which statements are executed and help programmers write structured and logical programs.
Flow of control refers to the sequence in which statements or function calls are executed within a program. In Python,
by default, the program runs from top to bottom, one line at a time. However, in many programming scenarios, the
order of execution needs to be altered based on certain conditions or requirements. This is where flow of control
statements come into play.
Flow of control allows a program to:
• Make decisions (which leads to branching, allowing different actions based on conditions).
• Repeat actions (by executing statements multiple times).
• Handle errors and exceptional situations (to ensure smooth program execution).
• Transfer control between different parts of the program (enabling the execution of specific blocks under certain
conditions).
In Python, flow of control is managed using:
• Conditional statements (if, elif, else) to make decisions
• Iterative statements (for, while) to repeat actions
• Control statements (break, continue) to alter the flow inside loops
These statements help make programs more flexible and dynamic, allowing the programmer to control how the code
is executed based on varying inputs or circumstances.
488 Touchpad Computer Science (Ver. 3.0)-XI

