尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
Loops in Python
hello!
I am Abhay Dhupar
I am here to teach you about LOOPS in Python.
You can find me at @abhaydhupar123@gmail.com
2
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
Airplane Airplane Airplane Airplane Airplane Airplane
3
What are Loops ?
print("Abhay")
print("Abhay")
print("Abhay")
print("Abhay")
print("Abhay")
print("Abhay")
print("Abhay")
print("Abhay")
print("Abhay")
print("Abhay")
4
Consider I want to print my name 10 times.
print("Abhay")
OR
A loop is used to repeat an instruction multiple times until a
condition goes wrong.
5
“
There are two primitive loop types in Python –
6
Types of Loops in Python
For in
loop
While
loop
A for in loop is used for iterating over a sequence (that is either a
list, a tuple, a dictionary, a set, or a string)
7
For in Loops
Syntax –
for counter in sequence :
statement(s)
A while loop is used to execute a set of statements as long as a
condition is true.
8
While Loops
Syntax –
while condition :
statement(s)
# for in loop
iterable_objs = range(6)
for iterator in iterable_objs:
print(iterator)
9
# while loop
i = 42
while not(i<=10):
print(i)
i -= 7
With the else statement, we can run a block of code once a
condition is no longer true.
10
The else Statement
Syntax –
while condition :
statement(s)
else :
statement(s)
Loop control statements change execution from its normal
sequence. There are 3 types –
11
Loop Control Statements
break
statement
continue
statement
pass
statement
# Break
for x in range(6):
if x==4:
break
print(x)
# Continue
for y in "Abhay":
if y=='h':
continue
print(y)
# Pass
mylist = [1,2,5,8,6,3]
for c in mylist:
pass
12
For in loop default increments by 1.
Else statement in loop won’t work if the loop is terminated
by break statement.
Nested loop is a type of non primitive loops in python.
In this, we can use multiple for or while loops inside a for or
while loop.
13
Points to be noted
Let’s review Today’s Learning
What is Loops in Python?
In this, we have understood the
basic meaning of loop and have
gone through definition of loops.
Benefits of using Loop
Here we have gone through some
examples which cleared why loops
are efficient and less time
consuming.
Types of Loop in Python
We have learned the two primitive
types of loops in Python and their
implementation.
Else statement in Loop
Here we have learned about the else
statement. It’s implementation and
where it works.
Loop Control Statements
Here, we have gone through the
three different loop statements in
Python. How and where they are
used.
Points to be noted
Here we have covered some extra
points related to our topics.
14
thanks! thanks! thanks! thanks! thanks! thanks! thanks!
thanks! thanks! thanks! thanks! thanks! thanks! thanks!
thanks! thanks! thanks! thanks! thanks! thanks! thanks!
thanks! thanks! thanks! thanks! thanks! thanks! thanks!
thanks! thanks! thanks! thanks! thanks! thanks! thanks!
thanks! thanks! thanks! thanks! thanks! thanks! thanks!
thanks! thanks! thanks! thanks! thanks! thanks! thanks!
thanks! thanks! thanks! thanks! thanks! thanks! thanks!
thanks! thanks! thanks! thanks! thanks! thanks! thanks!
15

More Related Content

What's hot

Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data types
Mohd Sajjad
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
PriyankaC44
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
nitamhaske
 
Data types in python
Data types in pythonData types in python
Data types in python
RaginiJain21
 
Python Modules
Python ModulesPython Modules
Python Modules
Nitin Reddy Katkam
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
Sumit Satam
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
Neeru Mittal
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
Dipankar Achinta
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
AkshayAggarwal79
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
Mohammed Sikander
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
Anusuya123
 
Introduction to pandas
Introduction to pandasIntroduction to pandas
Introduction to pandas
Piyush rai
 
Python recursion
Python recursionPython recursion
Python recursion
Prof. Dr. K. Adisesha
 
Sets in python
Sets in pythonSets in python
Linked list
Linked listLinked list
Linked list
akshat360
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
Rokonuzzaman Rony
 
String Manipulation in Python
String Manipulation in PythonString Manipulation in Python
String Manipulation in Python
Pooja B S
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
ismailmrribi
 
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
 

What's hot (20)

Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data types
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Python Modules
Python ModulesPython Modules
Python Modules
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
 
Introduction to pandas
Introduction to pandasIntroduction to pandas
Introduction to pandas
 
Python recursion
Python recursionPython recursion
Python recursion
 
Sets in python
Sets in pythonSets in python
Sets in python
 
Linked list
Linked listLinked list
Linked list
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
String Manipulation in Python
String Manipulation in PythonString Manipulation in Python
String Manipulation in Python
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 

Similar to Loops in Python

3-Module - Basic Python jUST _ aUTOMATE.pptx.pdf
3-Module - Basic Python  jUST _ aUTOMATE.pptx.pdf3-Module - Basic Python  jUST _ aUTOMATE.pptx.pdf
3-Module - Basic Python jUST _ aUTOMATE.pptx.pdf
RajeevPramanik1
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
CHANDAN KUMAR
 
6 Iterative Statements.pptx
6 Iterative Statements.pptx6 Iterative Statements.pptx
6 Iterative Statements.pptx
ssuser8e50d8
 
Control_Statements_in_Python.pptx
Control_Statements_in_Python.pptxControl_Statements_in_Python.pptx
Control_Statements_in_Python.pptx
Koteswari Kasireddy
 
An Introduction to Computer Science with Java, Python an.docx
An Introduction to  Computer Science  with Java, Python an.docxAn Introduction to  Computer Science  with Java, Python an.docx
An Introduction to Computer Science with Java, Python an.docx
amrit47
 
Python made easy
Python made easy Python made easy
Python made easy
Abhishek kumar
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
Kamal Acharya
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
bsdeol28
 
Mastering Python lesson 3a
Mastering Python lesson 3aMastering Python lesson 3a
Mastering Python lesson 3a
Ruth Marvin
 
Notes2
Notes2Notes2
Notes2
hccit
 
5. php bangla tutorial php basic
5. php bangla tutorial php basic5. php bangla tutorial php basic
5. php bangla tutorial php basic
SamimKhan19
 
PYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMSPYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMS
Aniruddha Paul
 
JAVA.pptx
JAVA.pptxJAVA.pptx
JAVA.pptx
JAVA.pptxJAVA.pptx
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
JavvajiVenkat
 
Polymorphism topic power point presentation li.pptx
Polymorphism topic power point presentation li.pptxPolymorphism topic power point presentation li.pptx
Polymorphism topic power point presentation li.pptx
MalligaarjunanN
 
Baabtra.com little coder chapter - 6
Baabtra.com little coder   chapter - 6Baabtra.com little coder   chapter - 6
Baabtra.com little coder chapter - 6
baabtra.com - No. 1 supplier of quality freshers
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & style
Kevlin Henney
 

Similar to Loops in Python (18)

3-Module - Basic Python jUST _ aUTOMATE.pptx.pdf
3-Module - Basic Python  jUST _ aUTOMATE.pptx.pdf3-Module - Basic Python  jUST _ aUTOMATE.pptx.pdf
3-Module - Basic Python jUST _ aUTOMATE.pptx.pdf
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
 
6 Iterative Statements.pptx
6 Iterative Statements.pptx6 Iterative Statements.pptx
6 Iterative Statements.pptx
 
Control_Statements_in_Python.pptx
Control_Statements_in_Python.pptxControl_Statements_in_Python.pptx
Control_Statements_in_Python.pptx
 
An Introduction to Computer Science with Java, Python an.docx
An Introduction to  Computer Science  with Java, Python an.docxAn Introduction to  Computer Science  with Java, Python an.docx
An Introduction to Computer Science with Java, Python an.docx
 
Python made easy
Python made easy Python made easy
Python made easy
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
Mastering Python lesson 3a
Mastering Python lesson 3aMastering Python lesson 3a
Mastering Python lesson 3a
 
Notes2
Notes2Notes2
Notes2
 
5. php bangla tutorial php basic
5. php bangla tutorial php basic5. php bangla tutorial php basic
5. php bangla tutorial php basic
 
PYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMSPYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMS
 
JAVA.pptx
JAVA.pptxJAVA.pptx
JAVA.pptx
 
JAVA.pptx
JAVA.pptxJAVA.pptx
JAVA.pptx
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
 
Polymorphism topic power point presentation li.pptx
Polymorphism topic power point presentation li.pptxPolymorphism topic power point presentation li.pptx
Polymorphism topic power point presentation li.pptx
 
Baabtra.com little coder chapter - 6
Baabtra.com little coder   chapter - 6Baabtra.com little coder   chapter - 6
Baabtra.com little coder chapter - 6
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & style
 

More from AbhayDhupar

JavaScript : A trending scripting language
JavaScript : A trending scripting languageJavaScript : A trending scripting language
JavaScript : A trending scripting language
AbhayDhupar
 
What is Data analytics and it's importance ?
What is Data analytics and it's importance ?What is Data analytics and it's importance ?
What is Data analytics and it's importance ?
AbhayDhupar
 
Internet & it's concepts
Internet & it's conceptsInternet & it's concepts
Internet & it's concepts
AbhayDhupar
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOC
AbhayDhupar
 
Successive Approximation ADC
Successive Approximation ADC Successive Approximation ADC
Successive Approximation ADC
AbhayDhupar
 
Food chain
Food chainFood chain
Food chain
AbhayDhupar
 
Edge computing
Edge computingEdge computing
Edge computing
AbhayDhupar
 
Sets and its types-
 Sets and its types- Sets and its types-
Sets and its types-
AbhayDhupar
 

More from AbhayDhupar (8)

JavaScript : A trending scripting language
JavaScript : A trending scripting languageJavaScript : A trending scripting language
JavaScript : A trending scripting language
 
What is Data analytics and it's importance ?
What is Data analytics and it's importance ?What is Data analytics and it's importance ?
What is Data analytics and it's importance ?
 
Internet & it's concepts
Internet & it's conceptsInternet & it's concepts
Internet & it's concepts
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOC
 
Successive Approximation ADC
Successive Approximation ADC Successive Approximation ADC
Successive Approximation ADC
 
Food chain
Food chainFood chain
Food chain
 
Edge computing
Edge computingEdge computing
Edge computing
 
Sets and its types-
 Sets and its types- Sets and its types-
Sets and its types-
 

Recently uploaded

Introduction to ThousandEyes AMER Webinar
Introduction  to ThousandEyes AMER WebinarIntroduction  to ThousandEyes AMER Webinar
Introduction to ThousandEyes AMER Webinar
ThousandEyes
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
Cyber Recovery Wargame
Cyber Recovery WargameCyber Recovery Wargame
Cyber Recovery Wargame
Databarracks
 
Facilitation Skills - When to Use and Why.pptx
Facilitation Skills - When to Use and Why.pptxFacilitation Skills - When to Use and Why.pptx
Facilitation Skills - When to Use and Why.pptx
Knoldus Inc.
 
Guidelines for Effective Data Visualization
Guidelines for Effective Data VisualizationGuidelines for Effective Data Visualization
Guidelines for Effective Data Visualization
UmmeSalmaM1
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
Day 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data ManipulationDay 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data Manipulation
UiPathCommunity
 
New ThousandEyes Product Features and Release Highlights: June 2024
New ThousandEyes Product Features and Release Highlights: June 2024New ThousandEyes Product Features and Release Highlights: June 2024
New ThousandEyes Product Features and Release Highlights: June 2024
ThousandEyes
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
Tobias Schneck
 
Discover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched ContentDiscover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched Content
ScyllaDB
 
CTO Insights: Steering a High-Stakes Database Migration
CTO Insights: Steering a High-Stakes Database MigrationCTO Insights: Steering a High-Stakes Database Migration
CTO Insights: Steering a High-Stakes Database Migration
ScyllaDB
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to SuccessDynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
ScyllaDB
 
Communications Mining Series - Zero to Hero - Session 2
Communications Mining Series - Zero to Hero - Session 2Communications Mining Series - Zero to Hero - Session 2
Communications Mining Series - Zero to Hero - Session 2
DianaGray10
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
Ortus Solutions, Corp
 
ScyllaDB Real-Time Event Processing with CDC
ScyllaDB Real-Time Event Processing with CDCScyllaDB Real-Time Event Processing with CDC
ScyllaDB Real-Time Event Processing with CDC
ScyllaDB
 

Recently uploaded (20)

Introduction to ThousandEyes AMER Webinar
Introduction  to ThousandEyes AMER WebinarIntroduction  to ThousandEyes AMER Webinar
Introduction to ThousandEyes AMER Webinar
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
Cyber Recovery Wargame
Cyber Recovery WargameCyber Recovery Wargame
Cyber Recovery Wargame
 
Facilitation Skills - When to Use and Why.pptx
Facilitation Skills - When to Use and Why.pptxFacilitation Skills - When to Use and Why.pptx
Facilitation Skills - When to Use and Why.pptx
 
Guidelines for Effective Data Visualization
Guidelines for Effective Data VisualizationGuidelines for Effective Data Visualization
Guidelines for Effective Data Visualization
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
Day 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data ManipulationDay 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data Manipulation
 
New ThousandEyes Product Features and Release Highlights: June 2024
New ThousandEyes Product Features and Release Highlights: June 2024New ThousandEyes Product Features and Release Highlights: June 2024
New ThousandEyes Product Features and Release Highlights: June 2024
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
 
Discover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched ContentDiscover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched Content
 
CTO Insights: Steering a High-Stakes Database Migration
CTO Insights: Steering a High-Stakes Database MigrationCTO Insights: Steering a High-Stakes Database Migration
CTO Insights: Steering a High-Stakes Database Migration
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to SuccessDynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
 
Communications Mining Series - Zero to Hero - Session 2
Communications Mining Series - Zero to Hero - Session 2Communications Mining Series - Zero to Hero - Session 2
Communications Mining Series - Zero to Hero - Session 2
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
 
ScyllaDB Real-Time Event Processing with CDC
ScyllaDB Real-Time Event Processing with CDCScyllaDB Real-Time Event Processing with CDC
ScyllaDB Real-Time Event Processing with CDC
 

Loops in Python

  • 2. hello! I am Abhay Dhupar I am here to teach you about LOOPS in Python. You can find me at @abhaydhupar123@gmail.com 2
  • 3. Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane Airplane 3
  • 4. What are Loops ? print("Abhay") print("Abhay") print("Abhay") print("Abhay") print("Abhay") print("Abhay") print("Abhay") print("Abhay") print("Abhay") print("Abhay") 4 Consider I want to print my name 10 times. print("Abhay") OR
  • 5. A loop is used to repeat an instruction multiple times until a condition goes wrong. 5 “
  • 6. There are two primitive loop types in Python – 6 Types of Loops in Python For in loop While loop
  • 7. A for in loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string) 7 For in Loops Syntax – for counter in sequence : statement(s)
  • 8. A while loop is used to execute a set of statements as long as a condition is true. 8 While Loops Syntax – while condition : statement(s)
  • 9. # for in loop iterable_objs = range(6) for iterator in iterable_objs: print(iterator) 9 # while loop i = 42 while not(i<=10): print(i) i -= 7
  • 10. With the else statement, we can run a block of code once a condition is no longer true. 10 The else Statement Syntax – while condition : statement(s) else : statement(s)
  • 11. Loop control statements change execution from its normal sequence. There are 3 types – 11 Loop Control Statements break statement continue statement pass statement
  • 12. # Break for x in range(6): if x==4: break print(x) # Continue for y in "Abhay": if y=='h': continue print(y) # Pass mylist = [1,2,5,8,6,3] for c in mylist: pass 12
  • 13. For in loop default increments by 1. Else statement in loop won’t work if the loop is terminated by break statement. Nested loop is a type of non primitive loops in python. In this, we can use multiple for or while loops inside a for or while loop. 13 Points to be noted
  • 14. Let’s review Today’s Learning What is Loops in Python? In this, we have understood the basic meaning of loop and have gone through definition of loops. Benefits of using Loop Here we have gone through some examples which cleared why loops are efficient and less time consuming. Types of Loop in Python We have learned the two primitive types of loops in Python and their implementation. Else statement in Loop Here we have learned about the else statement. It’s implementation and where it works. Loop Control Statements Here, we have gone through the three different loop statements in Python. How and where they are used. Points to be noted Here we have covered some extra points related to our topics. 14
  • 15. thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! thanks! 15
  翻译: