SlideShare a Scribd company logo
3
Most read
4
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

PPTX
python conditional statement.pptx
PPTX
Functions in python slide share
PPTX
Variables in python
PPTX
Python ppt
PDF
Algorithms Lecture 1: Introduction to Algorithms
PDF
Introduction to Python
PPTX
Python basics
PPTX
Python for loop
python conditional statement.pptx
Functions in python slide share
Variables in python
Python ppt
Algorithms Lecture 1: Introduction to Algorithms
Introduction to Python
Python basics
Python for loop

What's hot (20)

PDF
Control Structures in Python
PDF
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
PPTX
Conditional and control statement
PPTX
Command line arguments
PDF
Datatypes in python
PPT
Chapter 5 -Syntax Directed Translation - Copy.ppt
PPTX
Functions in Python
PPTX
Python Functions
PDF
Python programming : Control statements
PPTX
PPTX
Python Libraries and Modules
PDF
Python Basics | Python Tutorial | Edureka
PPTX
Procedural programming
PDF
Python tuple
PDF
Operators in python
PDF
Python Flow Control
PPTX
serializability in dbms
PPTX
For Loops and Nesting in Python
PPTX
Introduction to python
Control Structures in Python
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Conditional and control statement
Command line arguments
Datatypes in python
Chapter 5 -Syntax Directed Translation - Copy.ppt
Functions in Python
Python Functions
Python programming : Control statements
Python Libraries and Modules
Python Basics | Python Tutorial | Edureka
Procedural programming
Python tuple
Operators in python
Python Flow Control
serializability in dbms
For Loops and Nesting in Python
Introduction to python
Ad

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

PPTX
PPT_203105211_3.pptx
PPTX
Python Flow Control
PPTX
Python if_else_loop_Control_Flow_Statement
PPTX
Control Structures Python like conditions and loops
PDF
E-Notes_3721_Content_Document_20250107032537PM.pdf
PPT
PPT3-CONDITIONAL STATEMENT LOOPS DICTIONARY FUNCTIONS.ppt
PDF
Slide 6_Control Structures.pdf
PPT
ppt3-conditionalstatementloopsdictionaryfunctions-240731050730-455ba0fa.ppt
PPT
Python session3
PPTX
python.pptx
DOCX
iterations.docx
PPTX
Module_2_1_Building Python Programs_Final.pptx
PPTX
1. control structures in the python.pptx
PDF
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
PPTX
Control_Statements.pptx
PPTX
ControlStructures.pptx5t54t54444444444444444
PDF
LOOPS TOPIC FOR CLASS XI PYTHON SYLLABUS
PDF
loops.pdf
PDF
basic of desicion control statement in python
PPTX
industry coding practice unit-2 ppt.pptx
PPT_203105211_3.pptx
Python Flow Control
Python if_else_loop_Control_Flow_Statement
Control Structures Python like conditions and loops
E-Notes_3721_Content_Document_20250107032537PM.pdf
PPT3-CONDITIONAL STATEMENT LOOPS DICTIONARY FUNCTIONS.ppt
Slide 6_Control Structures.pdf
ppt3-conditionalstatementloopsdictionaryfunctions-240731050730-455ba0fa.ppt
Python session3
python.pptx
iterations.docx
Module_2_1_Building Python Programs_Final.pptx
1. control structures in the python.pptx
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
Control_Statements.pptx
ControlStructures.pptx5t54t54444444444444444
LOOPS TOPIC FOR CLASS XI PYTHON SYLLABUS
loops.pdf
basic of desicion control statement in python
industry coding practice unit-2 ppt.pptx
Ad

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
cuic standard and advanced reporting.pdf
PDF
Approach and Philosophy of On baking technology
PPT
Teaching material agriculture food technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Cloud computing and distributed systems.
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Modernizing your data center with Dell and AMD
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Electronic commerce courselecture one. Pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
cuic standard and advanced reporting.pdf
Approach and Philosophy of On baking technology
Teaching material agriculture food technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
20250228 LYD VKU AI Blended-Learning.pptx
Cloud computing and distributed systems.
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Weekly Chronicles - August'25 Week I
Understanding_Digital_Forensics_Presentation.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Modernizing your data center with Dell and AMD
Chapter 3 Spatial Domain Image Processing.pdf
Encapsulation theory and applications.pdf
Digital-Transformation-Roadmap-for-Companies.pptx

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.