尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
Python Flow Control
Python if...else
Python for Loop
Python while Loop
Python break and continue
Python Pass
Python if...else
• What are if statement in Python?
• Python if Statement Syntax
• Python if Statement Flowchart
• Example: Python if Statement
• Python if...else Statement
• Syntax of if...else
• Python if..else Flowchart
• Example of if...else
• Python if...elif...else Statement
• Syntax of if...elif...else
• Flowchart of if...elif...else
• Example of if...elif...else
• Python Nested if statements
Python if Statement Syntax
• Syntax
Python if Statement Flowchart
Example:
Output
Syntax of if...else
• Syntax
Python if..else Flowchart
Example of if...else
Output
Syntax of if...elif...else
• Syntax
Flowchart of if...elif...else
Example of if...elif...else
Output
Python Nested if statements
Output
Python for Loop
• What is for loop in Python?
• Syntax of for Loop
• Flowchart of for loop
• Example: Python for Loop
• The range() function
• for loop with else
What is 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:
• Here, val is the variable that takes the value of the item inside the
sequence on each iteration
• Loop continues until we reach the last item in the sequence. The body
of for loop is separated from the rest of the code using indentation.
Flowchart of for Loop
Example
The range() function
• Can generate a sequence of numbers using range() function
• range(10) will generate numbers from 0 to 9 (10 numbers)
• Can also define the start, stop and step size as
range(start,stop,stepsize)
• Step size defaults to 1 if not provided.
• Does not store all the values in memory, it would be inefficient
• So it remembers the start, stop, step size and generates the next
number on the go
Example
for loop with else
Python while Loop
• What is while loop in Python?
• Syntax of while Loop in Python
• Flowchart of while loop
• Example: Python while Loop
• while loop with else
What is while loop in Python?
• Is used to iterate over a block of code as long as the test expression
(condition) is true
• Generally this loop is used when we don't know beforehand, the
number of times to iterate
Syntax of while Loop in Python
• Python interprets any non-zero value as True. None and 0 are
interpreted as False.
Flowchart of while Loop
Example
while loop with else
Python break and continue
• What is the use of break and continue in Python?
• Python break statement
• Syntax of break
• Flowchart of break
• Example of break
• Python continue statement
• Syntax of Continue
• Flowchart of continue
• Example: Python continue
What is the use of 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 test expression is false, but
sometimes we wish to terminate the current iteration or even the
whole loop without checking test expression
• break and continue statements are used in these cases
Python break statement
• Terminates the loop containing it
• Control of the program flows to the statement immediately after the
body of the loop.
• If break statement is inside a nested loop (loop inside another loop),
break will terminate the innermost loop
• Syntax of break
Flowchart of break
Example
Python 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
• Syntax of Continue
Flowchart of continue
Example
Python pass statement
• What is pass statement in Python?
• Syntax of pass
• Example: pass Statement
What is pass statement in Python?
• pass is a null statement
• The difference between a comment and pass statement in Python is
that, while the interpreter ignores a comment entirely, pass is not
ignored
• However, nothing happens when pass is executed
• It results into no operation (NOP)
• Syntax of pass
Example
Example
Thank You !

More Related Content

What's hot

Python Lambda Function
Python Lambda FunctionPython Lambda Function
Python Lambda Function
Md Soyaib
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
Jothi Thilaga P
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
vikram mahendra
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
Kamal Acharya
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Python Modules
Python ModulesPython Modules
Python Modules
Nitin Reddy Katkam
 
Python basic
Python basicPython basic
Python basic
Saifuddin Kaijar
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
Siddique Ibrahim
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
Haitham El-Ghareeb
 
Variables & Data Types In Python | Edureka
Variables & Data Types In Python | EdurekaVariables & Data Types In Python | Edureka
Variables & Data Types In Python | Edureka
Edureka!
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
Rasan Samarasinghe
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
Dipankar Achinta
 
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Edureka!
 
Data types in python
Data types in pythonData types in python
Data types in python
RaginiJain21
 
Python : Data Types
Python : Data TypesPython : Data Types
Python final ppt
Python final pptPython final ppt
Python final ppt
Ripal Ranpara
 
Python Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsPython Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular Expressions
Ranel Padon
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Edureka!
 
Python made easy
Python made easy Python made easy
Python made easy
Abhishek kumar
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
VINOTH R
 

What's hot (20)

Python Lambda Function
Python Lambda FunctionPython Lambda Function
Python Lambda Function
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
Python Modules
Python ModulesPython Modules
Python Modules
 
Python basic
Python basicPython basic
Python basic
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Variables & Data Types In Python | Edureka
Variables & Data Types In Python | EdurekaVariables & Data Types In Python | Edureka
Variables & Data Types In Python | Edureka
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
 
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Python Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsPython Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular Expressions
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
 
Python made easy
Python made easy Python made easy
Python made easy
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 

Similar to Python Flow Control

com.pptx
com.pptxcom.pptx
Break, Continue and Pass in Python.pdf
Break, Continue and Pass in Python.pdfBreak, Continue and Pass in Python.pdf
Break, Continue and Pass in Python.pdf
NehaSpillai1
 
Control_Statements_in_Python.pptx
Control_Statements_in_Python.pptxControl_Statements_in_Python.pptx
Control_Statements_in_Python.pptx
Koteswari Kasireddy
 
This is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptxThis is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptx
elezearrepil1
 
6 Iterative Statements.pptx
6 Iterative Statements.pptx6 Iterative Statements.pptx
6 Iterative Statements.pptx
ssuser8e50d8
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
TKSanthoshRao
 
Introduction to Python Part-1
Introduction to Python Part-1Introduction to Python Part-1
Introduction to Python Part-1
Devashish Kumar
 
Python if_else_loop_Control_Flow_Statement
Python if_else_loop_Control_Flow_StatementPython if_else_loop_Control_Flow_Statement
Python if_else_loop_Control_Flow_Statement
AbhishekGupta692777
 
Python Tutorial for Beginner
Python Tutorial for BeginnerPython Tutorial for Beginner
Python Tutorial for Beginner
rajkamaltibacademy
 
While-For-loop in python used in college
While-For-loop in python used in collegeWhile-For-loop in python used in college
While-For-loop in python used in college
ssuser7a7cd61
 
While_for_loop presententationin first year students
While_for_loop presententationin first year studentsWhile_for_loop presententationin first year students
While_for_loop presententationin first year students
SIHIGOPAL
 
Python session3
Python session3Python session3
Python session3
Aswin Krishnamoorthy
 
Programming in python - Week 4
Programming in python  - Week 4Programming in python  - Week 4
Programming in python - Week 4
Priya Nayak
 
python ppt.pptx
python ppt.pptxpython ppt.pptx
python ppt.pptx
ssuserd10678
 
3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf
santosh147365
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
Akhil Kaushik
 
03 conditions loops
03   conditions loops03   conditions loops
03 conditions loops
Manzoor ALam
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scripting
Amirul Shafeeq
 
Control_Statements.pptx
Control_Statements.pptxControl_Statements.pptx
Control_Statements.pptx
Koteswari Kasireddy
 
2. python basic syntax
2. python   basic syntax2. python   basic syntax
2. python basic syntax
Soba Arjun
 

Similar to Python Flow Control (20)

com.pptx
com.pptxcom.pptx
com.pptx
 
Break, Continue and Pass in Python.pdf
Break, Continue and Pass in Python.pdfBreak, Continue and Pass in Python.pdf
Break, Continue and Pass in Python.pdf
 
Control_Statements_in_Python.pptx
Control_Statements_in_Python.pptxControl_Statements_in_Python.pptx
Control_Statements_in_Python.pptx
 
This is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptxThis is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptx
 
6 Iterative Statements.pptx
6 Iterative Statements.pptx6 Iterative Statements.pptx
6 Iterative Statements.pptx
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 
Introduction to Python Part-1
Introduction to Python Part-1Introduction to Python Part-1
Introduction to Python Part-1
 
Python if_else_loop_Control_Flow_Statement
Python if_else_loop_Control_Flow_StatementPython if_else_loop_Control_Flow_Statement
Python if_else_loop_Control_Flow_Statement
 
Python Tutorial for Beginner
Python Tutorial for BeginnerPython Tutorial for Beginner
Python Tutorial for Beginner
 
While-For-loop in python used in college
While-For-loop in python used in collegeWhile-For-loop in python used in college
While-For-loop in python used in college
 
While_for_loop presententationin first year students
While_for_loop presententationin first year studentsWhile_for_loop presententationin first year students
While_for_loop presententationin first year students
 
Python session3
Python session3Python session3
Python session3
 
Programming in python - Week 4
Programming in python  - Week 4Programming in python  - Week 4
Programming in python - Week 4
 
python ppt.pptx
python ppt.pptxpython ppt.pptx
python ppt.pptx
 
3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
 
03 conditions loops
03   conditions loops03   conditions loops
03 conditions loops
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scripting
 
Control_Statements.pptx
Control_Statements.pptxControl_Statements.pptx
Control_Statements.pptx
 
2. python basic syntax
2. python   basic syntax2. python   basic syntax
2. python basic syntax
 

More from Kamal Acharya

Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
Kamal Acharya
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
Kamal Acharya
 
Introduction to Computer Security
Introduction to Computer SecurityIntroduction to Computer Security
Introduction to Computer Security
Kamal Acharya
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
Kamal Acharya
 
Functions in php
Functions in phpFunctions in php
Functions in php
Kamal Acharya
 
Web forms in php
Web forms in phpWeb forms in php
Web forms in php
Kamal Acharya
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHP
Kamal Acharya
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in php
Kamal Acharya
 
Text and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHPText and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHP
Kamal Acharya
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Kamal Acharya
 
Capacity Planning of Data Warehousing
Capacity Planning of Data WarehousingCapacity Planning of Data Warehousing
Capacity Planning of Data Warehousing
Kamal Acharya
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
Kamal Acharya
 
Search Engines
Search EnginesSearch Engines
Search Engines
Kamal Acharya
 
Web Mining
Web MiningWeb Mining
Web Mining
Kamal Acharya
 
Information Privacy and Data Mining
Information Privacy and Data MiningInformation Privacy and Data Mining
Information Privacy and Data Mining
Kamal Acharya
 
Cluster Analysis
Cluster AnalysisCluster Analysis
Cluster Analysis
Kamal Acharya
 
Association Analysis in Data Mining
Association Analysis in Data MiningAssociation Analysis in Data Mining
Association Analysis in Data Mining
Kamal Acharya
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data mining
Kamal Acharya
 
Data Preprocessing
Data PreprocessingData Preprocessing
Data Preprocessing
Kamal Acharya
 
Introduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data WarehousingIntroduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data Warehousing
Kamal Acharya
 

More from Kamal Acharya (20)

Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
 
Introduction to Computer Security
Introduction to Computer SecurityIntroduction to Computer Security
Introduction to Computer Security
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
 
Functions in php
Functions in phpFunctions in php
Functions in php
 
Web forms in php
Web forms in phpWeb forms in php
Web forms in php
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHP
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in php
 
Text and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHPText and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHP
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Capacity Planning of Data Warehousing
Capacity Planning of Data WarehousingCapacity Planning of Data Warehousing
Capacity Planning of Data Warehousing
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
Search Engines
Search EnginesSearch Engines
Search Engines
 
Web Mining
Web MiningWeb Mining
Web Mining
 
Information Privacy and Data Mining
Information Privacy and Data MiningInformation Privacy and Data Mining
Information Privacy and Data Mining
 
Cluster Analysis
Cluster AnalysisCluster Analysis
Cluster Analysis
 
Association Analysis in Data Mining
Association Analysis in Data MiningAssociation Analysis in Data Mining
Association Analysis in Data Mining
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data mining
 
Data Preprocessing
Data PreprocessingData Preprocessing
Data Preprocessing
 
Introduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data WarehousingIntroduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data Warehousing
 

Recently uploaded

Post init hook in the odoo 17 ERP Module
Post init hook in the  odoo 17 ERP ModulePost init hook in the  odoo 17 ERP Module
Post init hook in the odoo 17 ERP Module
Celine George
 
Non-Verbal Communication for Tech Professionals
Non-Verbal Communication for Tech ProfessionalsNon-Verbal Communication for Tech Professionals
Non-Verbal Communication for Tech Professionals
MattVassar1
 
managing Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptxmanaging Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptx
nabaegha
 
nutrition in plants chapter 1 class 7...
nutrition in plants chapter 1 class 7...nutrition in plants chapter 1 class 7...
nutrition in plants chapter 1 class 7...
chaudharyreet2244
 
The Rise of the Digital Telecommunication Marketplace.pptx
The Rise of the Digital Telecommunication Marketplace.pptxThe Rise of the Digital Telecommunication Marketplace.pptx
The Rise of the Digital Telecommunication Marketplace.pptx
PriyaKumari928991
 
Decolonizing Universal Design for Learning
Decolonizing Universal Design for LearningDecolonizing Universal Design for Learning
Decolonizing Universal Design for Learning
Frederic Fovet
 
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT KanpurDiversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
Quiz Club IIT Kanpur
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
Kalna College
 
The basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptxThe basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptx
heathfieldcps1
 
bryophytes.pptx bsc botany honours second semester
bryophytes.pptx bsc botany honours  second semesterbryophytes.pptx bsc botany honours  second semester
bryophytes.pptx bsc botany honours second semester
Sarojini38
 
Interprofessional Education Platform Introduction.pdf
Interprofessional Education Platform Introduction.pdfInterprofessional Education Platform Introduction.pdf
Interprofessional Education Platform Introduction.pdf
Ben Aldrich
 
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
biruktesfaye27
 
How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17
Celine George
 
Cross-Cultural Leadership and Communication
Cross-Cultural Leadership and CommunicationCross-Cultural Leadership and Communication
Cross-Cultural Leadership and Communication
MattVassar1
 
What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17
Celine George
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
sanamushtaq922
 
220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
Kalna College
 
Erasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES CroatiaErasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES Croatia
whatchangedhowreflec
 
Get Success with the Latest UiPath UIPATH-ADPV1 Exam Dumps (V11.02) 2024
Get Success with the Latest UiPath UIPATH-ADPV1 Exam Dumps (V11.02) 2024Get Success with the Latest UiPath UIPATH-ADPV1 Exam Dumps (V11.02) 2024
Get Success with the Latest UiPath UIPATH-ADPV1 Exam Dumps (V11.02) 2024
yarusun
 
IoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdfIoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdf
roshanranjit222
 

Recently uploaded (20)

Post init hook in the odoo 17 ERP Module
Post init hook in the  odoo 17 ERP ModulePost init hook in the  odoo 17 ERP Module
Post init hook in the odoo 17 ERP Module
 
Non-Verbal Communication for Tech Professionals
Non-Verbal Communication for Tech ProfessionalsNon-Verbal Communication for Tech Professionals
Non-Verbal Communication for Tech Professionals
 
managing Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptxmanaging Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptx
 
nutrition in plants chapter 1 class 7...
nutrition in plants chapter 1 class 7...nutrition in plants chapter 1 class 7...
nutrition in plants chapter 1 class 7...
 
The Rise of the Digital Telecommunication Marketplace.pptx
The Rise of the Digital Telecommunication Marketplace.pptxThe Rise of the Digital Telecommunication Marketplace.pptx
The Rise of the Digital Telecommunication Marketplace.pptx
 
Decolonizing Universal Design for Learning
Decolonizing Universal Design for LearningDecolonizing Universal Design for Learning
Decolonizing Universal Design for Learning
 
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT KanpurDiversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
 
The basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptxThe basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptx
 
bryophytes.pptx bsc botany honours second semester
bryophytes.pptx bsc botany honours  second semesterbryophytes.pptx bsc botany honours  second semester
bryophytes.pptx bsc botany honours second semester
 
Interprofessional Education Platform Introduction.pdf
Interprofessional Education Platform Introduction.pdfInterprofessional Education Platform Introduction.pdf
Interprofessional Education Platform Introduction.pdf
 
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
 
How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17
 
Cross-Cultural Leadership and Communication
Cross-Cultural Leadership and CommunicationCross-Cultural Leadership and Communication
Cross-Cultural Leadership and Communication
 
What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
 
220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
 
Erasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES CroatiaErasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES Croatia
 
Get Success with the Latest UiPath UIPATH-ADPV1 Exam Dumps (V11.02) 2024
Get Success with the Latest UiPath UIPATH-ADPV1 Exam Dumps (V11.02) 2024Get Success with the Latest UiPath UIPATH-ADPV1 Exam Dumps (V11.02) 2024
Get Success with the Latest UiPath UIPATH-ADPV1 Exam Dumps (V11.02) 2024
 
IoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdfIoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdf
 

Python Flow Control

  • 1. Python Flow Control Python if...else Python for Loop Python while Loop Python break and continue Python Pass
  • 2. Python if...else • What are if statement in Python? • Python if Statement Syntax • Python if Statement Flowchart • Example: Python if Statement • Python if...else Statement • Syntax of if...else • Python if..else Flowchart • Example of if...else • Python if...elif...else Statement • Syntax of if...elif...else • Flowchart of if...elif...else • Example of if...elif...else • Python Nested if statements
  • 3. Python if Statement Syntax • Syntax
  • 15. Python Nested if statements
  • 17. Python for Loop • What is for loop in Python? • Syntax of for Loop • Flowchart of for loop • Example: Python for Loop • The range() function • for loop with else
  • 18. What is 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
  • 19. • Syntax of for Loop: • Here, val is the variable that takes the value of the item inside the sequence on each iteration • Loop continues until we reach the last item in the sequence. The body of for loop is separated from the rest of the code using indentation.
  • 22.
  • 23. The range() function • Can generate a sequence of numbers using range() function • range(10) will generate numbers from 0 to 9 (10 numbers) • Can also define the start, stop and step size as range(start,stop,stepsize) • Step size defaults to 1 if not provided. • Does not store all the values in memory, it would be inefficient • So it remembers the start, stop, step size and generates the next number on the go
  • 25.
  • 27. Python while Loop • What is while loop in Python? • Syntax of while Loop in Python • Flowchart of while loop • Example: Python while Loop • while loop with else
  • 28. What is while loop in Python? • Is used to iterate over a block of code as long as the test expression (condition) is true • Generally this loop is used when we don't know beforehand, the number of times to iterate
  • 29. Syntax of while Loop in Python • Python interprets any non-zero value as True. None and 0 are interpreted as False.
  • 32.
  • 34.
  • 35. Python break and continue • What is the use of break and continue in Python? • Python break statement • Syntax of break • Flowchart of break • Example of break • Python continue statement • Syntax of Continue • Flowchart of continue • Example: Python continue
  • 36. What is the use of 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 test expression is false, but sometimes we wish to terminate the current iteration or even the whole loop without checking test expression • break and continue statements are used in these cases
  • 37. Python break statement • Terminates the loop containing it • Control of the program flows to the statement immediately after the body of the loop. • If break statement is inside a nested loop (loop inside another loop), break will terminate the innermost loop • Syntax of break
  • 40.
  • 41. Python 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 • Syntax of Continue
  • 44.
  • 45. Python pass statement • What is pass statement in Python? • Syntax of pass • Example: pass Statement
  • 46. What is pass statement in Python? • pass is a null statement • The difference between a comment and pass statement in Python is that, while the interpreter ignores a comment entirely, pass is not ignored • However, nothing happens when pass is executed • It results into no operation (NOP) • Syntax of pass
  翻译: