0% found this document useful (0 votes)
2 views2 pages

Control Structures in Python

The document explains control structures in Python, which influence the flow of program execution. It categorizes them into sequential statements, selection statements (like if and if-else), and iterative statements (such as for and while loops). Each type of control structure serves a specific purpose in programming to manage how code is executed based on conditions or sequences.

Uploaded by

vivaanjindal119
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Control Structures in Python

The document explains control structures in Python, which influence the flow of program execution. It categorizes them into sequential statements, selection statements (like if and if-else), and iterative statements (such as for and while loops). Each type of control structure serves a specific purpose in programming to manage how code is executed based on conditions or sequences.

Uploaded by

vivaanjindal119
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Control Structures in Python

CONTROL STRUCTURE
A control structure is a programming construct which affects the flow of execution of a
program.
Various types of control structures provided by Python are shown below:

Control Structure:
- Sequential Statements
- Selection Statements
- Iterative Statements

SEQUENTIAL STATEMENTS
The statements that are executed in a sequential order, i.e., one after the other without any
jumps
are called sequential statements. A sequential structure is also known as a straight line path.
- Statement 1
- Statement 2
- Statement 3

SELECTION STATEMENTS
Some problems cannot be solved by performing a set of ordered steps as seen in a
sequential execution.
When programmers are required to execute a particular set of statements depending upon
a particular
test condition, a selection or decision making statement is required. Python provides the
following
selection statements:
(i) if statement
(ii) if-else
(iii) if-elif-else statement

THE if STATEMENT
The if statement is a decision-making statement which is used to control the flow of
execution of statements.

THE if-else STATEMENT


The if-else statement is used to evaluate whether a given condition is true or false.
If the condition is true, the if block is executed. If the given condition is false,
the else block is executed.
ITERATIVE STATEMENTS
Iterative statements, also known as looping statements, are programming constructs used
to
repeat a task based on a given condition. An iteration refers to one pass of a loop.

In Python, the two primary iterative statements are:


(i) For loop: Used to iterate over a sequence (like a list, tuple, string, or range) or
other iterable objects.
(ii) While loop: Used to repeatedly execute a block of code as long as a given condition is
true.

THE FOR LOOP


The for loop is an iterative statement that enables users to repeatedly execute a block of
statements until a specified condition becomes false. It is commonly utilized when the
number
of repetitions is known in advance. Additionally, the for loop is the preferred choice for
tasks involving array manipulation and traversal.

You might also like