CONTROL STRUCTURE IN PYTHON PROGRAMMING
PART III
Prepared By
P. K. Nakhate
CONTROL FLOW STATEMENTS,�
The flow control statements are divided into three categories
CONDITIONAL STATEMENTS�
In Python, condition statements act depending on whether a given condition is true or false. You can execute different blocks of codes depending on the outcome of a condition. Condition statements always evaluate to either True or False.
There are three types of conditional statements.
ITERATIVE STATEMENTS
In Python, iterative statements allow us to execute a block of code repeatedly as long as the condition is True. We also call it a loop statements.
Python provides us the following two loop statement to perform some actions repeatedly
TRANSFER STATEMENTS
In Python, transfer statements are used to alter the program’s way of execution in a certain manner. For this purpose, we use three types of transfer statements.
IF STATEMENT IN PYTHON�
In control statements, The if statement is the simplest form. It takes a condition and
evaluates to either True or False.
If the condition is True, then the True block of code will be executed,
and if the condition is False, then the block of code is skipped, and The controller moves to the next line
Syntax of the if statement
if condition:
statement 1
statement 2
statement n
IF – ELSE STATEMENT
CHAIN MULTIPLE IF STATEMENT IN PYTHON�
NESTED IF-ELSE STATEMENT
SINGLE STATEMENT SUITES�
FOR LOOP IN PYTHON
Using for loop, we can iterate any sequence or iterable variable. The sequence can be string, list, dictionary, set, or tuple.
While loop in Python
In Python, The while loop statement repeatedly executes a code block while a particular condition is true.
In a while-loop, every time the condition is checked at the beginning of the loop, and if it is true, then the loop’s body gets executed. When the condition became False, the controller comes out of the block.
Break Statement in Python
Continue statement in python
Pass statement in Python
Thank You