SlideShare a Scribd company logo
• 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

What's hot

C++ control structure
C++ control structureC++ control structure
C++ control structure
bluejayjunior
 
Looping statement
Looping statementLooping statement
Looping statement
ilakkiya
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structure
Jd Mercado
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
Jin Castor
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
bsdeol28
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
Jeya Lakshmi
 

What's hot (20)

Java loops
Java loopsJava loops
Java loops
 
Loops in java script
Loops in java scriptLoops in java script
Loops in java script
 
Iteration
IterationIteration
Iteration
 
C++ control structure
C++ control structureC++ control structure
C++ control structure
 
C++ loop
C++ loop C++ loop
C++ loop
 
Nested loops
Nested loopsNested loops
Nested loops
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 
Loop c++
Loop c++Loop c++
Loop c++
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Looping statement
Looping statementLooping statement
Looping statement
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structure
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
Repetition Structure
Repetition StructureRepetition Structure
Repetition Structure
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
130707833146508191
130707833146508191130707833146508191
130707833146508191
 
Loops in c
Loops in cLoops in c
Loops in c
 
Loops c++
Loops c++Loops c++
Loops c++
 

Viewers also liked

20 C programs
20 C programs20 C programs
20 C programs
navjoth
 
C programs
C programsC programs
C programs
Minu S
 

Viewers also liked (20)

Formatting Output
Formatting  OutputFormatting  Output
Formatting Output
 
Computer Logic
Computer LogicComputer Logic
Computer Logic
 
Functions
FunctionsFunctions
Functions
 
Function Returns
Function ReturnsFunction Returns
Function Returns
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsPython Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
 
Year 7 lesson 5 if statements
Year 7 lesson 5   if statementsYear 7 lesson 5   if statements
Year 7 lesson 5 if statements
 
Connect all your customers on one multichannel platform!
Connect all your customers on one multichannel platform!Connect all your customers on one multichannel platform!
Connect all your customers on one multichannel platform!
 
Input
InputInput
Input
 
Logical Operators
Logical OperatorsLogical Operators
Logical Operators
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Variables and Expressions
Variables and ExpressionsVariables and Expressions
Variables and Expressions
 
20 C programs
20 C programs20 C programs
20 C programs
 
Python in raspberry pi
Python in raspberry piPython in raspberry pi
Python in raspberry pi
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Python
 
Cloud Computing to Internet of Things
Cloud Computing to Internet of ThingsCloud Computing to Internet of Things
Cloud Computing to Internet of Things
 
Got Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIOGot Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIO
 
CS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUALCS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUAL
 
Internet of Things for Libraries
Internet of Things for LibrariesInternet of Things for Libraries
Internet of Things for Libraries
 
C programs
C programsC programs
C programs
 

Similar to Conditional Loops Python

ICPSR - Complex Systems Models in the Social Sciences - Lab Session 7, 8 - Pr...
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 7, 8 - Pr...ICPSR - Complex Systems Models in the Social Sciences - Lab Session 7, 8 - Pr...
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 7, 8 - Pr...
Daniel Katz
 
classVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxclassVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptx
ssusere336f4
 
Going loopy - Introduction to Loops.pptx
Going loopy - Introduction to Loops.pptxGoing loopy - Introduction to Loops.pptx
Going loopy - Introduction to Loops.pptx
Amy Nightingale
 
Week04
Week04Week04
Week04
hccit
 
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 6 - Profe...
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 6 - Profe...ICPSR - Complex Systems Models in the Social Sciences - Lab Session 6 - Profe...
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 6 - Profe...
Daniel Katz
 

Similar to Conditional Loops Python (20)

Introduction to Repetition Structures
Introduction to Repetition StructuresIntroduction to Repetition Structures
Introduction to Repetition Structures
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Conditional Loops
Conditional LoopsConditional Loops
Conditional Loops
 
Programming loop
Programming loopProgramming loop
Programming loop
 
Repitition Structure
Repitition StructureRepitition Structure
Repitition Structure
 
Repetition, Basic loop structures, Loop programming techniques
Repetition, Basic loop structures, Loop programming techniquesRepetition, Basic loop structures, Loop programming techniques
Repetition, Basic loop structures, Loop programming techniques
 
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 7, 8 - Pr...
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 7, 8 - Pr...ICPSR - Complex Systems Models in the Social Sciences - Lab Session 7, 8 - Pr...
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 7, 8 - Pr...
 
Lesson 5
Lesson 5Lesson 5
Lesson 5
 
classVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxclassVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptx
 
C language (Part 2)
C language (Part 2)C language (Part 2)
C language (Part 2)
 
Going loopy - Introduction to Loops.pptx
Going loopy - Introduction to Loops.pptxGoing loopy - Introduction to Loops.pptx
Going loopy - Introduction to Loops.pptx
 
JAN CARL BRIONES-Writing Programs Using Loops.pptx
JAN CARL BRIONES-Writing Programs Using Loops.pptxJAN CARL BRIONES-Writing Programs Using Loops.pptx
JAN CARL BRIONES-Writing Programs Using Loops.pptx
 
Week04
Week04Week04
Week04
 
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 6 - Profe...
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 6 - Profe...ICPSR - Complex Systems Models in the Social Sciences - Lab Session 6 - Profe...
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 6 - Profe...
 
Slide 6_Control Structures.pdf
Slide 6_Control Structures.pdfSlide 6_Control Structures.pdf
Slide 6_Control Structures.pdf
 
control structure
control structurecontrol structure
control structure
 
Loops
LoopsLoops
Loops
 
Visula C# Programming Lecture 4
Visula C# Programming Lecture 4Visula C# Programming Lecture 4
Visula C# Programming Lecture 4
 
cpu.pdf
cpu.pdfcpu.pdf
cpu.pdf
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 

More from primeteacher32 (20)

Software Development Life Cycle
Software Development Life CycleSoftware Development Life Cycle
Software Development Life Cycle
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
 
Returning Data
Returning DataReturning Data
Returning Data
 
Intro to Functions
Intro to FunctionsIntro to Functions
Intro to Functions
 
Introduction to GUIs with guizero
Introduction to GUIs with guizeroIntroduction to GUIs with guizero
Introduction to GUIs with guizero
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
Nested Loops
Nested LoopsNested Loops
Nested Loops
 
Input Validation
Input ValidationInput Validation
Input Validation
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
 
Nesting Conditionals
Nesting ConditionalsNesting Conditionals
Nesting Conditionals
 
Conditionals
ConditionalsConditionals
Conditionals
 
Intro to Python with GPIO
Intro to Python with GPIOIntro to Python with GPIO
Intro to Python with GPIO
 
Variables and Statements
Variables and StatementsVariables and Statements
Variables and Statements
 
Variables and User Input
Variables and User InputVariables and User Input
Variables and User Input
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Hardware vs. Software Presentations
Hardware vs. Software PresentationsHardware vs. Software Presentations
Hardware vs. Software Presentations
 
Block chain security
Block chain securityBlock chain security
Block chain security
 
Hashes
HashesHashes
Hashes
 
System Administration
System AdministrationSystem Administration
System Administration
 

Recently uploaded

皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
larisashrestha558
 
Dr. Nazrul Islam, Northern University Bangladesh - CV (29.5.2024).pdf
Dr. Nazrul Islam, Northern University Bangladesh - CV (29.5.2024).pdfDr. Nazrul Islam, Northern University Bangladesh - CV (29.5.2024).pdf
Dr. Nazrul Islam, Northern University Bangladesh - CV (29.5.2024).pdf
Dr. Nazrul Islam
 
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Dirk Spencer Corporate Recruiter LION
 

Recently uploaded (20)

0524.THOMASGIRARD_SINGLEPAGERESUME-01.pdf
0524.THOMASGIRARD_SINGLEPAGERESUME-01.pdf0524.THOMASGIRARD_SINGLEPAGERESUME-01.pdf
0524.THOMASGIRARD_SINGLEPAGERESUME-01.pdf
 
132. Acta Scientific Pharmaceutical Sciences
132. Acta Scientific Pharmaceutical Sciences132. Acta Scientific Pharmaceutical Sciences
132. Acta Scientific Pharmaceutical Sciences
 
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
 
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
 
Widal Agglutination Test: A rapid serological diagnosis of typhoid fever
Widal Agglutination Test: A rapid serological diagnosis of typhoid feverWidal Agglutination Test: A rapid serological diagnosis of typhoid fever
Widal Agglutination Test: A rapid serological diagnosis of typhoid fever
 
135. Reviewer Certificate in Journal of Engineering
135. Reviewer Certificate in Journal of Engineering135. Reviewer Certificate in Journal of Engineering
135. Reviewer Certificate in Journal of Engineering
 
D.El.Ed. College List -Session 2024-26.pdf
D.El.Ed. College List -Session 2024-26.pdfD.El.Ed. College List -Session 2024-26.pdf
D.El.Ed. College List -Session 2024-26.pdf
 
Biography and career history of Chad Henson.pdf
Biography and career history of Chad Henson.pdfBiography and career history of Chad Henson.pdf
Biography and career history of Chad Henson.pdf
 
129. Reviewer Certificate in BioNature [2024]
129. Reviewer Certificate in BioNature [2024]129. Reviewer Certificate in BioNature [2024]
129. Reviewer Certificate in BioNature [2024]
 
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
 
DIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptxDIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptx
 
0524.priorspeakingengagementslist-01.pdf
0524.priorspeakingengagementslist-01.pdf0524.priorspeakingengagementslist-01.pdf
0524.priorspeakingengagementslist-01.pdf
 
134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science
 
欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】
欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】
欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】
 
0524.THOMASGIRARD_CURRICULUMVITAE-01.pdf
0524.THOMASGIRARD_CURRICULUMVITAE-01.pdf0524.THOMASGIRARD_CURRICULUMVITAE-01.pdf
0524.THOMASGIRARD_CURRICULUMVITAE-01.pdf
 
Dr. Nazrul Islam, Northern University Bangladesh - CV (29.5.2024).pdf
Dr. Nazrul Islam, Northern University Bangladesh - CV (29.5.2024).pdfDr. Nazrul Islam, Northern University Bangladesh - CV (29.5.2024).pdf
Dr. Nazrul Islam, Northern University Bangladesh - CV (29.5.2024).pdf
 
Operating system. short answes and Interview questions .pdf
Operating system. short answes and Interview questions .pdfOperating system. short answes and Interview questions .pdf
Operating system. short answes and Interview questions .pdf
 
133. Reviewer Certificate in Advances in Research
133. Reviewer Certificate in Advances in Research133. Reviewer Certificate in Advances in Research
133. Reviewer Certificate in Advances in Research
 
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
 
欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
 

Conditional Loops Python

  • 1.
  • 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