SlideShare a Scribd company logo
2
Most read
4
Most read
5
Most read
Conditional Loops Python
• An application sometimes needs to perform
repetitive actions like:
 Summing Numbers(Averages)
 Entering Multiple Data Entries
 Prompting the User Till the Correct Value is Entered
 A shopping list(scanning through the shopping list and
getting the items 1 by one until the list is down and
then you leave)
 
• When a program repeatedly runs a set of
statements it is referred to as a loop, iteration
or repetition structure.
• There are several types of looping structures:
 While Loops
 Do-While Loops
 For Loops
Counter Controlled Loops
Condional Loops
• Loops are similar to conditionals because they run
on a true/false value set. The loop continuously
runs while the condition is true and terminates
when it is false.
• Loops can be run for a desired length or until a
flag terminates them
 Great technique to reuse code and therefore limit
the amount of statements a program needs. Reusing
the same conditional arguments for testing instead
of posting hundreds.
True
False
 Question: How many statements are needed
for the following?
 Ask the same question 100 times
 Store the answer in a variable
 Check whether the answer is one of two answers
 Question: How many statements are needed if
we loop the code?
• A While Loop is a loop that executes 0 or more times
before terminating.
• Pre-conditional loop
 Code:
 Creating a While Loop:
 while (condition statement):
statement1
statement2
 
 Debugging Techniques:
 Setup a counter to keep track of the number of times a loop runs
 Set up a counter to count if an event is occurring or the number
of times it occurs
 Output values each time a loop executes
num = eval(input(“Enter a number less than 10:”))
while (number >= 10):
print(“Invalid Entry!”)
num = eval(input(“Enter a number less than 10:”))
 Counter: a variable that is incremented or
decremented each time a loop repeats
 Can be used to control execution of the loop
(also known as the loop control variable)
 Must be initialized before entering loop
Conditional Loops Python
Conditional Loops Python

More Related Content

PPTX
For Loops and Nesting in Python
primeteacher32
 
PDF
Control statements
Kanwalpreet Kaur
 
PPTX
C# Loops
Hock Leng PUAH
 
DOC
Conditional statements in vb script
Nilanjan Saha
 
PPT
Java Programming: Loops
Karwan Mustafa Kareem
 
PDF
Loops and conditional statements
Saad Sheikh
 
PDF
Control statements anil
Anil Dutt
 
For Loops and Nesting in Python
primeteacher32
 
Control statements
Kanwalpreet Kaur
 
C# Loops
Hock Leng PUAH
 
Conditional statements in vb script
Nilanjan Saha
 
Java Programming: Loops
Karwan Mustafa Kareem
 
Loops and conditional statements
Saad Sheikh
 
Control statements anil
Anil Dutt
 

What's hot (20)

DOCX
Java loops
ricardovigan
 
PPTX
Loops in java script
Ravi Bhadauria
 
PPT
Iteration
Liam Dunphy
 
PDF
C++ control structure
bluejayjunior
 
PPTX
C++ loop
Khelan Ameen
 
PPTX
Nested loops
Neeru Mittal
 
PPT
Looping in c++
deekshagopaliya
 
PPSX
C lecture 4 nested loops and jumping statements slideshare
Gagan Deep
 
PPTX
Loop c++
Mood Mood
 
PDF
Chapter 3
Amrit Kaur
 
PPTX
Looping statement
ilakkiya
 
PPTX
Do...while loop structure
Jd Mercado
 
PPT
Looping statements in Java
Jin Castor
 
PPTX
Presentation on nesting of loops
bsdeol28
 
PPT
Repetition Structure
PRN USM
 
PPTX
Looping statements in C
Jeya Lakshmi
 
PPTX
Loops in C Programming Language
Mahantesh Devoor
 
PPTX
130707833146508191
Tanzeel Ahmad
 
PPTX
Loops c++
Shivani Singh
 
Java loops
ricardovigan
 
Loops in java script
Ravi Bhadauria
 
Iteration
Liam Dunphy
 
C++ control structure
bluejayjunior
 
C++ loop
Khelan Ameen
 
Nested loops
Neeru Mittal
 
Looping in c++
deekshagopaliya
 
C lecture 4 nested loops and jumping statements slideshare
Gagan Deep
 
Loop c++
Mood Mood
 
Chapter 3
Amrit Kaur
 
Looping statement
ilakkiya
 
Do...while loop structure
Jd Mercado
 
Looping statements in Java
Jin Castor
 
Presentation on nesting of loops
bsdeol28
 
Repetition Structure
PRN USM
 
Looping statements in C
Jeya Lakshmi
 
Loops in C Programming Language
Mahantesh Devoor
 
130707833146508191
Tanzeel Ahmad
 
Loops c++
Shivani Singh
 
Ad

Viewers also liked (20)

PPT
Formatting Output
primeteacher32
 
PPTX
Computer Logic
primeteacher32
 
PPTX
Functions
primeteacher32
 
PPTX
Function Returns
primeteacher32
 
PPTX
Python Programming Essentials - M16 - Control Flow Statements and Loops
P3 InfoTech Solutions Pvt. Ltd.
 
PPTX
Year 7 lesson 5 if statements
tmoncrieff
 
PDF
Connect all your customers on one multichannel platform!
Slawomir Kluczewski
 
PPT
Input
primeteacher32
 
PPTX
Logical Operators
primeteacher32
 
PPT
Intro to Python
primeteacher32
 
PPTX
Variables and Expressions
primeteacher32
 
DOC
20 C programs
navjoth
 
PPTX
Python in raspberry pi
Sudar Muthu
 
PPTX
C programming language tutorial
javaTpoint s
 
PDF
Socket Programming In Python
didip
 
PDF
Cloud Computing to Internet of Things
HermesDDS
 
PPTX
Got Python I/O: IoT Develoment in Python via GPIO
Adam Englander
 
DOC
CS2309 JAVA LAB MANUAL
Lavanya Arunachalam A
 
PDF
Internet of Things for Libraries
Nicole Baratta
 
DOCX
C programs
Minu S
 
Formatting Output
primeteacher32
 
Computer Logic
primeteacher32
 
Functions
primeteacher32
 
Function Returns
primeteacher32
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
P3 InfoTech Solutions Pvt. Ltd.
 
Year 7 lesson 5 if statements
tmoncrieff
 
Connect all your customers on one multichannel platform!
Slawomir Kluczewski
 
Logical Operators
primeteacher32
 
Intro to Python
primeteacher32
 
Variables and Expressions
primeteacher32
 
20 C programs
navjoth
 
Python in raspberry pi
Sudar Muthu
 
C programming language tutorial
javaTpoint s
 
Socket Programming In Python
didip
 
Cloud Computing to Internet of Things
HermesDDS
 
Got Python I/O: IoT Develoment in Python via GPIO
Adam Englander
 
CS2309 JAVA LAB MANUAL
Lavanya Arunachalam A
 
Internet of Things for Libraries
Nicole Baratta
 
C programs
Minu S
 
Ad

Similar to Conditional Loops Python (20)

PDF
Repetition, Basic loop structures, Loop programming techniques
Jason J Pulikkottil
 
PPT
Conditional Loops
primeteacher32
 
PPTX
Introduction to Repetition Structures
primeteacher32
 
PPT
Fundamentals of Programming Chapter 7
Mohd Harris Ahmad Jaal
 
PPTX
While loop
RabiyaZhexembayeva
 
PDF
Pseudocode By ZAK
Tabsheer Hasan
 
PDF
Slide 6_Control Structures.pdf
NuthalapatiSasidhar
 
PDF
nuts and bolts of c++
guestfb6ada
 
PDF
Flow control in c++
Subhasis Nayak
 
PDF
Loops
Learn By Watch
 
PPTX
Mastering Python lesson 3a
Ruth Marvin
 
PPTX
5 Repetition Structures
Kwan Lee
 
PPT
Loop Statements [5] M
ecko_disasterz
 
PPTX
Fundamentals of Programming Lecture #1.pptx
Eyasu46
 
PDF
2 Python Basics II meeting 2 tunghai university pdf
Anggi Andriyadi
 
PDF
Python_Module_2.pdf
R.K.College of engg & Tech
 
PPT
Programming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;J
AlthimeseAnderson
 
PPT
Python Control structures
Siddique Ibrahim
 
PDF
loopingstatementinpython-210628184047 (1).pdf
DheeravathBinduMadha
 
PPTX
python ppt.pptx
ssuserd10678
 
Repetition, Basic loop structures, Loop programming techniques
Jason J Pulikkottil
 
Conditional Loops
primeteacher32
 
Introduction to Repetition Structures
primeteacher32
 
Fundamentals of Programming Chapter 7
Mohd Harris Ahmad Jaal
 
While loop
RabiyaZhexembayeva
 
Pseudocode By ZAK
Tabsheer Hasan
 
Slide 6_Control Structures.pdf
NuthalapatiSasidhar
 
nuts and bolts of c++
guestfb6ada
 
Flow control in c++
Subhasis Nayak
 
Mastering Python lesson 3a
Ruth Marvin
 
5 Repetition Structures
Kwan Lee
 
Loop Statements [5] M
ecko_disasterz
 
Fundamentals of Programming Lecture #1.pptx
Eyasu46
 
2 Python Basics II meeting 2 tunghai university pdf
Anggi Andriyadi
 
Python_Module_2.pdf
R.K.College of engg & Tech
 
Programming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;J
AlthimeseAnderson
 
Python Control structures
Siddique Ibrahim
 
loopingstatementinpython-210628184047 (1).pdf
DheeravathBinduMadha
 
python ppt.pptx
ssuserd10678
 

More from primeteacher32 (20)

PPT
Software Development Life Cycle
primeteacher32
 
PPTX
Variable Scope
primeteacher32
 
PPTX
Returning Data
primeteacher32
 
PPTX
Intro to Functions
primeteacher32
 
PPTX
Introduction to GUIs with guizero
primeteacher32
 
PPTX
Function Parameters
primeteacher32
 
PPTX
Nested Loops
primeteacher32
 
PPTX
Input Validation
primeteacher32
 
PPTX
Windows File Systems
primeteacher32
 
PPTX
Nesting Conditionals
primeteacher32
 
PPTX
Conditionals
primeteacher32
 
PPT
Intro to Python with GPIO
primeteacher32
 
PPTX
Variables and Statements
primeteacher32
 
PPTX
Variables and User Input
primeteacher32
 
PPT
Intro to Python
primeteacher32
 
PPTX
Raspberry Pi
primeteacher32
 
PPT
Hardware vs. Software Presentations
primeteacher32
 
PPTX
Block chain security
primeteacher32
 
PPTX
Hashes
primeteacher32
 
PPTX
System Administration
primeteacher32
 
Software Development Life Cycle
primeteacher32
 
Variable Scope
primeteacher32
 
Returning Data
primeteacher32
 
Intro to Functions
primeteacher32
 
Introduction to GUIs with guizero
primeteacher32
 
Function Parameters
primeteacher32
 
Nested Loops
primeteacher32
 
Input Validation
primeteacher32
 
Windows File Systems
primeteacher32
 
Nesting Conditionals
primeteacher32
 
Conditionals
primeteacher32
 
Intro to Python with GPIO
primeteacher32
 
Variables and Statements
primeteacher32
 
Variables and User Input
primeteacher32
 
Intro to Python
primeteacher32
 
Raspberry Pi
primeteacher32
 
Hardware vs. Software Presentations
primeteacher32
 
Block chain security
primeteacher32
 
System Administration
primeteacher32
 

Recently uploaded (20)

DOCX
(14-5) Bo-15-De-luyen-thi-vao-10-Ha-Noi-25-26.docx
27QuynNhnChu
 
PPTX
jinsha and arif-2.pptx blood factors and diseases
arifkhansm29
 
PDF
Meatball of Canyon Valley sequence 2 storyboard by Mark G.
MarkGalez
 
PDF
reStartEvents 8:7 Nationwide All-Clearances Employer Directory.pdf
Ken Fuller
 
PDF
Copy of HKISO FINAL ROUND Session 1 & 2 - S3 and SS.pdf
nothisispatrickduhh
 
PPTX
LESSON 5 TLE 7SDHSJFJDFHDJFHDJFEWFFFEDDDD
roeltabuyo4
 
PPTX
9e3e3981-1864-438b-93b4-ebabcb5090d0.pptx
SureshKumar565390
 
PPTX
Green White Modern Clean Running Presentation.pptx
Johnjuru
 
PPTX
MASTERING COMMUNICATION SKILLS.pptxgdee33w
akramm8009
 
PPTX
锡根大学文凭办理|办理Uni Siegen毕业证电子版成绩单在线办理办成绩单
xxxihn4u
 
PDF
Applying Lean Six Sigma in Pre-Sales & Pre-Development: Setting the Stage for...
alekhyamandadi1
 
PPT
Gas turbine mark VIe control basics tool box description
aliyu4ahmad
 
PDF
Invincible season 2 storyboard revisions seq3 by Mark G
MarkGalez
 
PPT
Leadership essentials to build your carrier
ahmedhasan769002
 
PDF
Left Holding the Bag sequence 2 Storyboard by Mark G
MarkGalez
 
PPTX
arif og 2.pptx defence mechanism of gingiva
arifkhansm29
 
PPTX
FIND ODD SHAPE OUT for placement activity.pptx
YESIMSMART
 
PPTX
Black and Green Modern Running Presentation.pptx
Johnjuru
 
PPTX
Capstone Professional Portfolio Melissa Alice
malice926
 
PDF
Left Holding the Bag sequence 3 Storyboard by Mark G.
MarkGalez
 
(14-5) Bo-15-De-luyen-thi-vao-10-Ha-Noi-25-26.docx
27QuynNhnChu
 
jinsha and arif-2.pptx blood factors and diseases
arifkhansm29
 
Meatball of Canyon Valley sequence 2 storyboard by Mark G.
MarkGalez
 
reStartEvents 8:7 Nationwide All-Clearances Employer Directory.pdf
Ken Fuller
 
Copy of HKISO FINAL ROUND Session 1 & 2 - S3 and SS.pdf
nothisispatrickduhh
 
LESSON 5 TLE 7SDHSJFJDFHDJFHDJFEWFFFEDDDD
roeltabuyo4
 
9e3e3981-1864-438b-93b4-ebabcb5090d0.pptx
SureshKumar565390
 
Green White Modern Clean Running Presentation.pptx
Johnjuru
 
MASTERING COMMUNICATION SKILLS.pptxgdee33w
akramm8009
 
锡根大学文凭办理|办理Uni Siegen毕业证电子版成绩单在线办理办成绩单
xxxihn4u
 
Applying Lean Six Sigma in Pre-Sales & Pre-Development: Setting the Stage for...
alekhyamandadi1
 
Gas turbine mark VIe control basics tool box description
aliyu4ahmad
 
Invincible season 2 storyboard revisions seq3 by Mark G
MarkGalez
 
Leadership essentials to build your carrier
ahmedhasan769002
 
Left Holding the Bag sequence 2 Storyboard by Mark G
MarkGalez
 
arif og 2.pptx defence mechanism of gingiva
arifkhansm29
 
FIND ODD SHAPE OUT for placement activity.pptx
YESIMSMART
 
Black and Green Modern Running Presentation.pptx
Johnjuru
 
Capstone Professional Portfolio Melissa Alice
malice926
 
Left Holding the Bag sequence 3 Storyboard by Mark G.
MarkGalez
 

Conditional Loops Python

  • 2. • An application sometimes needs to perform repetitive actions like:  Summing Numbers(Averages)  Entering Multiple Data Entries  Prompting the User Till the Correct Value is Entered  A shopping list(scanning through the shopping list and getting the items 1 by one until the list is down and then you leave)  
  • 3. • When a program repeatedly runs a set of statements it is referred to as a loop, iteration or repetition structure. • There are several types of looping structures:  While Loops  Do-While Loops  For Loops Counter Controlled Loops Condional Loops
  • 4. • Loops are similar to conditionals because they run on a true/false value set. The loop continuously runs while the condition is true and terminates when it is false. • Loops can be run for a desired length or until a flag terminates them  Great technique to reuse code and therefore limit the amount of statements a program needs. Reusing the same conditional arguments for testing instead of posting hundreds. True False
  • 5.  Question: How many statements are needed for the following?  Ask the same question 100 times  Store the answer in a variable  Check whether the answer is one of two answers  Question: How many statements are needed if we loop the code?
  • 6. • A While Loop is a loop that executes 0 or more times before terminating. • Pre-conditional loop  Code:  Creating a While Loop:  while (condition statement): statement1 statement2    Debugging Techniques:  Setup a counter to keep track of the number of times a loop runs  Set up a counter to count if an event is occurring or the number of times it occurs  Output values each time a loop executes
  • 7. num = eval(input(“Enter a number less than 10:”)) while (number >= 10): print(“Invalid Entry!”) num = eval(input(“Enter a number less than 10:”))
  • 8.  Counter: a variable that is incremented or decremented each time a loop repeats  Can be used to control execution of the loop (also known as the loop control variable)  Must be initialized before entering loop