SlideShare ist ein Scribd-Unternehmen logo
1 von 49
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 !

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
 
Python Exception Handling
Python Exception HandlingPython Exception Handling
Python Exception Handling
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Python functions
Python functionsPython functions
Python functions
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python ppt
Python pptPython ppt
Python ppt
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Strings in python
Strings in pythonStrings in python
Strings in python
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python tuple
Python   tuplePython   tuple
Python tuple
 
Python list
Python listPython list
Python list
 
Python Modules
Python ModulesPython Modules
Python Modules
 

Ähnlich wie Python Flow Control

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.pdfNehaSpillai1
 
Control_Statements_in_Python.pptx
Control_Statements_in_Python.pptxControl_Statements_in_Python.pptx
Control_Statements_in_Python.pptxKoteswari 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.pptxelezearrepil1
 
6 Iterative Statements.pptx
6 Iterative Statements.pptx6 Iterative Statements.pptx
6 Iterative Statements.pptxssuser8e50d8
 
Introduction to Python Part-1
Introduction to Python Part-1Introduction to Python Part-1
Introduction to Python Part-1Devashish 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_StatementAbhishekGupta692777
 
Break, continue and return
Break, continue and return Break, continue and return
Break, continue and return Jadavsejal
 
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 collegessuser7a7cd61
 
Programming in python - Week 4
Programming in python  - Week 4Programming in python  - Week 4
Programming in python - Week 4Priya Nayak
 
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).pdfsantosh147365
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & LoopsAkhil Kaushik
 
03 conditions loops
03   conditions loops03   conditions loops
03 conditions loopsManzoor ALam
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scriptingAmirul Shafeeq
 
2. python basic syntax
2. python   basic syntax2. python   basic syntax
2. python basic syntaxSoba Arjun
 

Ähnlich wie 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
 
Break, continue and return
Break, continue and return Break, continue and return
Break, continue and return
 
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
 
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
 

Mehr von Kamal Acharya

Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computerKamal Acharya
 
Introduction to Computer Security
Introduction to Computer SecurityIntroduction to Computer Security
Introduction to Computer SecurityKamal Acharya
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHPKamal Acharya
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in phpKamal 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 PHPKamal Acharya
 
Capacity Planning of Data Warehousing
Capacity Planning of Data WarehousingCapacity Planning of Data Warehousing
Capacity Planning of Data WarehousingKamal Acharya
 
Information Privacy and Data Mining
Information Privacy and Data MiningInformation Privacy and Data Mining
Information Privacy and Data MiningKamal Acharya
 
Association Analysis in Data Mining
Association Analysis in Data MiningAssociation Analysis in Data Mining
Association Analysis in Data MiningKamal Acharya
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data miningKamal 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 WarehousingKamal Acharya
 

Mehr von 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
 

Kürzlich hochgeladen

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 

Kürzlich hochgeladen (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

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