SlideShare a Scribd company logo
2
Most read
3
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
PDF
Control statements
PPTX
C# Loops
DOC
Conditional statements in vb script
PPT
Java Programming: Loops
PDF
Loops and conditional statements
PDF
Control statements anil
For Loops and Nesting in Python
Control statements
C# Loops
Conditional statements in vb script
Java Programming: Loops
Loops and conditional statements
Control statements anil

What's hot (20)

DOCX
Java loops
PPTX
Loops in java script
PPT
Iteration
PDF
C++ control structure
PPTX
C++ loop
PPTX
Nested loops
PPT
Looping in c++
PPSX
C lecture 4 nested loops and jumping statements slideshare
PPTX
Loop c++
PDF
Chapter 3
PPTX
Looping statement
PPTX
Do...while loop structure
PPT
Looping statements in Java
PPTX
Presentation on nesting of loops
PPT
Repetition Structure
PPTX
Looping statements in C
PPTX
Loops in C Programming Language
PPTX
130707833146508191
PPTX
Loops c++
Java loops
Loops in java script
Iteration
C++ control structure
C++ loop
Nested loops
Looping in c++
C lecture 4 nested loops and jumping statements slideshare
Loop c++
Chapter 3
Looping statement
Do...while loop structure
Looping statements in Java
Presentation on nesting of loops
Repetition Structure
Looping statements in C
Loops in C Programming Language
130707833146508191
Loops c++
Ad

Viewers also liked (20)

PPT
Formatting Output
PPTX
Computer Logic
PPTX
Functions
PPTX
Function Returns
PPTX
Python Programming Essentials - M16 - Control Flow Statements and Loops
PPTX
Year 7 lesson 5 if statements
PDF
Connect all your customers on one multichannel platform!
PPT
PPTX
Logical Operators
PPT
Intro to Python
PPTX
Variables and Expressions
DOC
20 C programs
PPTX
Python in raspberry pi
PPTX
C programming language tutorial
PDF
Socket Programming In Python
PDF
Cloud Computing to Internet of Things
PPTX
Got Python I/O: IoT Develoment in Python via GPIO
DOC
CS2309 JAVA LAB MANUAL
PDF
Internet of Things for Libraries
DOCX
C programs
Formatting Output
Computer Logic
Functions
Function Returns
Python Programming Essentials - M16 - Control Flow Statements and Loops
Year 7 lesson 5 if statements
Connect all your customers on one multichannel platform!
Logical Operators
Intro to Python
Variables and Expressions
20 C programs
Python in raspberry pi
C programming language tutorial
Socket Programming In Python
Cloud Computing to Internet of Things
Got Python I/O: IoT Develoment in Python via GPIO
CS2309 JAVA LAB MANUAL
Internet of Things for Libraries
C programs
Ad

Similar to Conditional Loops Python (20)

PDF
Repetition, Basic loop structures, Loop programming techniques
PPT
Conditional Loops
PPTX
Introduction to Repetition Structures
PPT
Fundamentals of Programming Chapter 7
PDF
LOOPS TOPIC FOR CLASS XI PYTHON SYLLABUS
PPTX
While loop
PDF
Pseudocode By ZAK
PDF
Slide 6_Control Structures.pdf
PDF
nuts and bolts of c++
PDF
Flow control in c++
PDF
PPTX
Mastering Python lesson 3a
PPTX
5 Repetition Structures
PPT
Loop Statements [5] M
PPTX
Fundamentals of Programming Lecture #1.pptx
PDF
2 Python Basics II meeting 2 tunghai university pdf
PDF
Python_Module_2.pdf
PPT
Programming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;J
PPT
Python Control structures
PDF
loopingstatementinpython-210628184047 (1).pdf
Repetition, Basic loop structures, Loop programming techniques
Conditional Loops
Introduction to Repetition Structures
Fundamentals of Programming Chapter 7
LOOPS TOPIC FOR CLASS XI PYTHON SYLLABUS
While loop
Pseudocode By ZAK
Slide 6_Control Structures.pdf
nuts and bolts of c++
Flow control in c++
Mastering Python lesson 3a
5 Repetition Structures
Loop Statements [5] M
Fundamentals of Programming Lecture #1.pptx
2 Python Basics II meeting 2 tunghai university pdf
Python_Module_2.pdf
Programming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;J
Python Control structures
loopingstatementinpython-210628184047 (1).pdf

More from primeteacher32 (20)

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

Recently uploaded (20)

PDF
Manager Resume for R, CL & Applying Online.pdf
PPTX
Your Guide to a Winning Interview Aug 2025.
PDF
Understanding the Rhetorical Situation Presentation in Blue Orange Muted Il_2...
PDF
Biography of Mohammad Anamul Haque Nayan
DOCX
How to Become a Criminal Profiler or Behavioural Analyst.docx
PDF
APNCET2025RESULT Result Result 2025 2025
PPTX
Surgical thesis protocol formation ppt.pptx
PPTX
AREAS OF SPECIALIZATION AND CAREER OPPORTUNITIES FOR COMMUNICATORS AND JOURNA...
PPTX
FINAL PPT.pptx cfyufuyfuyuy8ioyoiuvy ituyc utdfm v
PPT
APPROACH TO DEVELOPMENTALlllllllllllllllll
PPTX
chapter 3_bem.pptxKLJLKJLKJLKJKJKLJKJKJKHJH
PPTX
ESD MODULE-5hdbdhbdbdbdbbdbdbbdndbdbdbdbbdbd
PPT
Gsisgdkddkvdgjsjdvdbdbdbdghjkhgcvvkkfcxxfg
PPTX
PMP (Project Management Professional) course prepares individuals
PPTX
Definition and Relation of Food Science( Lecture1).pptx
PDF
Why Today’s Brands Need ORM & SEO Specialists More Than Ever.pdf
PDF
Blue-Modern-Elegant-Presentation (1).pdf
PPTX
Job-opportunities lecture about it skills
PPTX
Autonomic_Nervous_SystemM_Drugs_PPT.pptx
PDF
Entrepreneurship PowerPoint for students
Manager Resume for R, CL & Applying Online.pdf
Your Guide to a Winning Interview Aug 2025.
Understanding the Rhetorical Situation Presentation in Blue Orange Muted Il_2...
Biography of Mohammad Anamul Haque Nayan
How to Become a Criminal Profiler or Behavioural Analyst.docx
APNCET2025RESULT Result Result 2025 2025
Surgical thesis protocol formation ppt.pptx
AREAS OF SPECIALIZATION AND CAREER OPPORTUNITIES FOR COMMUNICATORS AND JOURNA...
FINAL PPT.pptx cfyufuyfuyuy8ioyoiuvy ituyc utdfm v
APPROACH TO DEVELOPMENTALlllllllllllllllll
chapter 3_bem.pptxKLJLKJLKJLKJKJKLJKJKJKHJH
ESD MODULE-5hdbdhbdbdbdbbdbdbbdndbdbdbdbbdbd
Gsisgdkddkvdgjsjdvdbdbdbdghjkhgcvvkkfcxxfg
PMP (Project Management Professional) course prepares individuals
Definition and Relation of Food Science( Lecture1).pptx
Why Today’s Brands Need ORM & SEO Specialists More Than Ever.pdf
Blue-Modern-Elegant-Presentation (1).pdf
Job-opportunities lecture about it skills
Autonomic_Nervous_SystemM_Drugs_PPT.pptx
Entrepreneurship PowerPoint for students

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