SlideShare a Scribd company logo
3
Most read
7
Most read
17
Most read
Flow Control & Statements
Python control structures
 According to the structure theorem, any computer
program can be written using the basic control
structures .
 A control structure (or flow of control) is a block of
programming that analyses variables and
chooses a direction in which to go based on given
parameters. In simple sentence, a control
structure is just a decision that the computer
makes. So, it is the basic decision-making
process
Flow of control
Flow of control through any given program is
implemented with three basic types of control
structures:
 Sequential,
 Selection
 Repetition
Selection
 Python if statements
Python if..else statements
 The else statement is to specify a block of code
to be executed, if the condition in the if statement
is false. Thus, the else clause ensures that a
sequence of statements is executed.
if..elif..else statements
Python Loop / Iteration
Statements
 Loops are one of the most important features in
computer programming languages . As the
name suggests is the process that get repeated
again and again
Every loop has 3 parts:
 Initialization
 Condition
 Updation
Iteration Statements
What is for loop in Python?
 The for loop in Python is used to iterate over a
sequence (list, tuple, string) or other iterable
objects.
 Iterating over a sequence is called traversal.
Syntax of for Loop
for val in sequence:
Body of for loop
The range() function
 We can generate a sequence of numbers
using range() function. range(10) will generate
numbers from 0 to 9 (10 numbers).
 We can also define the start, stop and step size
as range(start, stop,step_size). step_size defaults
to 1 if not provided.
Examples :
 print(range(10))
 Print(list(range(10))
 print(list(range(2, 8)))
 print(list(range(2, 20, 3)))
for loop with else
 A for loop can have an optional else block as well.
The else part is executed if the items in the
sequence used in for loop exhausts.
digits = [0, 1, 5]
for i in digits:
print(i)
else:
print("No items left.")
What is while loop in Python?
 The while loop in Python is used to iterate over a
block of code as long as the test expression
(condition) is true.
Python break and continue
 In Python, break and continue statements can alter
the flow of a normal loop.
 Loops iterate over a block of code until the test
expression is false, but sometimes we wish to
terminate the current iteration or even the whole loop
without checking test expression.
 The break statement terminates the loop containing it.
Control of the program flows to the statement
immediately after the body of the loop.
 The continue statement is used to skip the rest of the
code inside a loop for the current iteration only. Loop
does not terminate but continues on with the next
iteration.
Python break statement
Syntax of break
break
The working of break statement in for
loop and while loop is shown below.
Python continue statement
The working of continue statement in
for and while loop is shown below.

More Related Content

What's hot (20)

PPTX
Chapter 07 inheritance
Praveen M Jigajinni
 
PPTX
Polymorphism in Python
Home
 
PPTX
OOPS In JAVA.pptx
Sachin33417
 
PDF
Python Flow Control
Mohammed Sikander
 
PPTX
Control Flow Statements
Tarun Sharma
 
PPT
Input and output in C++
Nilesh Dalvi
 
PPT
FUNCTIONS IN c++ PPT
03062679929
 
PPTX
Python Functions
Mohammed Sikander
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPTX
Chapter 05 classes and objects
Praveen M Jigajinni
 
ODP
Python Modules
Nitin Reddy Katkam
 
PPTX
Strings in c++
Neeru Mittal
 
PPTX
Python Exception Handling
Megha V
 
PPTX
Dynamic memory allocation in c
lavanya marichamy
 
PPTX
File Handling Python
Akhil Kaushik
 
PPT
Java interfaces
Raja Sekhar
 
PPTX
Type conversion
PreethaPreetha5
 
PDF
Python libraries
Prof. Dr. K. Adisesha
 
PPTX
File in C language
Manash Kumar Mondal
 
PPTX
Class, object and inheritance in python
Santosh Verma
 
Chapter 07 inheritance
Praveen M Jigajinni
 
Polymorphism in Python
Home
 
OOPS In JAVA.pptx
Sachin33417
 
Python Flow Control
Mohammed Sikander
 
Control Flow Statements
Tarun Sharma
 
Input and output in C++
Nilesh Dalvi
 
FUNCTIONS IN c++ PPT
03062679929
 
Python Functions
Mohammed Sikander
 
07. Virtual Functions
Haresh Jaiswal
 
Chapter 05 classes and objects
Praveen M Jigajinni
 
Python Modules
Nitin Reddy Katkam
 
Strings in c++
Neeru Mittal
 
Python Exception Handling
Megha V
 
Dynamic memory allocation in c
lavanya marichamy
 
File Handling Python
Akhil Kaushik
 
Java interfaces
Raja Sekhar
 
Type conversion
PreethaPreetha5
 
Python libraries
Prof. Dr. K. Adisesha
 
File in C language
Manash Kumar Mondal
 
Class, object and inheritance in python
Santosh Verma
 

Similar to Types of Statements in Python Programming Language (20)

PPTX
PPT_203105211_3.pptx
SaurabhNage1
 
PPTX
Python Flow Control
Kamal Acharya
 
PPTX
Python if_else_loop_Control_Flow_Statement
AbhishekGupta692777
 
PPTX
Control Structures Python like conditions and loops
ramireddyobulakondar
 
PDF
E-Notes_3721_Content_Document_20250107032537PM.pdf
aayushihirpara297
 
PPT
PPT3-CONDITIONAL STATEMENT LOOPS DICTIONARY FUNCTIONS.ppt
RahulKumar812056
 
PDF
Slide 6_Control Structures.pdf
NuthalapatiSasidhar
 
PPT
ppt3-conditionalstatementloopsdictionaryfunctions-240731050730-455ba0fa.ppt
avishekpradhan24
 
PPT
Python session3
Aswin Krishnamoorthy
 
PPTX
python.pptx
Poornima116356
 
DOCX
iterations.docx
ssuser2e84e4
 
PPTX
Module_2_1_Building Python Programs_Final.pptx
nikhithavarghese77
 
PPTX
1. control structures in the python.pptx
DURAIMURUGANM2
 
PPTX
Conditional and control statement
narmadhakin
 
PDF
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
sdvdsvsdvsvds
 
PPTX
Control_Statements.pptx
Koteswari Kasireddy
 
PPTX
ControlStructures.pptx5t54t54444444444444444
pawankamal3
 
PDF
loops.pdf
AmayJaiswal4
 
PDF
basic of desicion control statement in python
nitamhaske
 
PPTX
industry coding practice unit-2 ppt.pptx
LakshmiMarineni
 
PPT_203105211_3.pptx
SaurabhNage1
 
Python Flow Control
Kamal Acharya
 
Python if_else_loop_Control_Flow_Statement
AbhishekGupta692777
 
Control Structures Python like conditions and loops
ramireddyobulakondar
 
E-Notes_3721_Content_Document_20250107032537PM.pdf
aayushihirpara297
 
PPT3-CONDITIONAL STATEMENT LOOPS DICTIONARY FUNCTIONS.ppt
RahulKumar812056
 
Slide 6_Control Structures.pdf
NuthalapatiSasidhar
 
ppt3-conditionalstatementloopsdictionaryfunctions-240731050730-455ba0fa.ppt
avishekpradhan24
 
Python session3
Aswin Krishnamoorthy
 
python.pptx
Poornima116356
 
iterations.docx
ssuser2e84e4
 
Module_2_1_Building Python Programs_Final.pptx
nikhithavarghese77
 
1. control structures in the python.pptx
DURAIMURUGANM2
 
Conditional and control statement
narmadhakin
 
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
sdvdsvsdvsvds
 
Control_Statements.pptx
Koteswari Kasireddy
 
ControlStructures.pptx5t54t54444444444444444
pawankamal3
 
loops.pdf
AmayJaiswal4
 
basic of desicion control statement in python
nitamhaske
 
industry coding practice unit-2 ppt.pptx
LakshmiMarineni
 
Ad

Recently uploaded (20)

PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Digital Circuits, important subject in CS
contactparinay1
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Ad

Types of Statements in Python Programming Language

  • 1. Flow Control & Statements
  • 2. Python control structures  According to the structure theorem, any computer program can be written using the basic control structures .  A control structure (or flow of control) is a block of programming that analyses variables and chooses a direction in which to go based on given parameters. In simple sentence, a control structure is just a decision that the computer makes. So, it is the basic decision-making process
  • 3. Flow of control Flow of control through any given program is implemented with three basic types of control structures:  Sequential,  Selection  Repetition
  • 5. Python if..else statements  The else statement is to specify a block of code to be executed, if the condition in the if statement is false. Thus, the else clause ensures that a sequence of statements is executed.
  • 7. Python Loop / Iteration Statements  Loops are one of the most important features in computer programming languages . As the name suggests is the process that get repeated again and again Every loop has 3 parts:  Initialization  Condition  Updation
  • 9. What is for loop in Python?  The for loop in Python is used to iterate over a sequence (list, tuple, string) or other iterable objects.  Iterating over a sequence is called traversal. Syntax of for Loop for val in sequence: Body of for loop
  • 10. The range() function  We can generate a sequence of numbers using range() function. range(10) will generate numbers from 0 to 9 (10 numbers).  We can also define the start, stop and step size as range(start, stop,step_size). step_size defaults to 1 if not provided. Examples :  print(range(10))  Print(list(range(10))  print(list(range(2, 8)))  print(list(range(2, 20, 3)))
  • 11. for loop with else  A for loop can have an optional else block as well. The else part is executed if the items in the sequence used in for loop exhausts. digits = [0, 1, 5] for i in digits: print(i) else: print("No items left.")
  • 12. What is while loop in Python?  The while loop in Python is used to iterate over a block of code as long as the test expression (condition) is true.
  • 13. Python break and continue  In Python, break and continue statements can alter the flow of a normal loop.  Loops iterate over a block of code until the test expression is false, but sometimes we wish to terminate the current iteration or even the whole loop without checking test expression.  The break statement terminates the loop containing it. Control of the program flows to the statement immediately after the body of the loop.  The continue statement is used to skip the rest of the code inside a loop for the current iteration only. Loop does not terminate but continues on with the next iteration.
  • 15. The working of break statement in for loop and while loop is shown below.
  • 17. The working of continue statement in for and while loop is shown below.