SlideShare a Scribd company logo
1 of 25
Little Coder Program
by
What you’ve learned?
How to compare conditions using if statements
What is block statements and importance of keeping equal spacing for
block statements
How to give else conditions
How to nest more than one If and else conditions
How to give multiple conditions inside the same if condition
LoopsChapter 6
Back to Anna !
• Do you remember this particular pink color block that you’ve used
for anna?
• We’ve used it whenever we wanted Anna to perform the same
instruction repeatedly. Similarly in python we use loops to repeat
some particular instructions
Loops
• That is, whenever you want a computer to repeat something over
and over again a loop instruction can be used. A loop is used to
make a computer do something more than one time.
Why Loops?
• Nothing is worse than having to do the same thing over and over
again. For example To print hello five times in Python, you could
do the following:
>>> print("hello")
hello
>>> print("hello")
hello
>>> print("hello")
hello
>>> print("hello")
hello
>>> print("hello")
hello
“It’s not tideous !! Rather we can try with loop as below
which is much neater”
>>> for x in range(0, 5):
print('hello')
hello
hello
hello
hello
hello
“It’s not tideous !! Rather we can try with loop as below
which is much neater”
>>> for x in range(0, 5):
print('hello')
hello
hello
hello
hello
hello
The range function can be used to create a
list of numbers with in a range
For example
>>>print(list(range(10, 20)))
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
Example
>>> for x in range(0, 5):
print('hello %s' % x)
Example
>>> for x in range(0, 5):
print('hello %s' % x)
Range(0,5) will return a list
of numbers from 0 to 5 as
below
[0,1,2,3,4,5]
Example
>>> for x in range(0, 5):
print('hello %s' % x)
[0,1,2,3,4,5]
x
x is a variable which will
have value 0 when the loop
executes for the first time.
Example
>>> for x in range(0, 5):
print('hello %s' % x)
[0,1,2,3,4,5]
x
Output
hello 0
1st Iteration
Example
>>> for x in range(0, 5):
print('hello %s' % x)
[0,1,2,3,4,5]
x
Output
hello 0
hello 1
2nd Iteration
Example
>>> for x in range(0, 5):
print('hello %s' % x)
[0,1,2,3,4,5]
x
Output
hello 0
hello 1
hello 2
3rd Iteration
Example
>>> for x in range(0, 5):
print('hello %s' % x)
[0,1,2,3,4,5]
x
Output
hello 0
hello 1
hello 2
hello 3
4th Iteration
Example
>>> for x in range(0, 5):
print('hello %s' % x)
[0,1,2,3,4,5]
x
Output
hello 0
hello 1
hello 2
hello 3
hello 4
5th Iteration
Example
>>> for x in range(0, 5):
print('hello %s' % x)
[0,1,2,3,4,5]
x
Output
hello 0
hello 1
hello 2
hello 3
hello 4
hello 5
6th Iteration
Loop with lists
Fruits=[‘orange’,’apple’,’grape’,’pappaya’,’banana’]
for i in fruits:
print(i)
Here we have
created a list
variable named
fruits
Loop with lists
Fruits=[‘orange’,’apple’,’grape’,’pappaya’,’banana’]
for i in fruits:
print(i)
Now we are using
the variable fruits
instead of calling
range() function.
Loop with lists
Fruits=[‘orange’,’apple’,’grape’,’pappaya’,’banana’]
for i in fruits:
print(i)
Output
Orange
Apple
Grape
Pappaya
banana
While Loop
While loop
• A for loop isn’t the only kind of loop you can make in Python.
There’s also the while loop. A for loop is a loop of a specific
length, whereas a while loop is a loop that is used when you don’t
know ahead of time when it needs to stop looping.
>>> x = 45
>>> y = 80
>>> while x < 50 and y < 100:
x = x + 1
y = y + 1
print(x, y)
Exercise !
Exercise !
• Print all the numbers between 350 and 450 using for loop
• Print all the even numbers below 100 using while loop
• Print all the odd numbers between 100 and 200 using while loop
End of Chapter 6

More Related Content

What's hot (6)

Conditionalstatement
ConditionalstatementConditionalstatement
Conditionalstatement
 
What is recursion?
What is recursion? What is recursion?
What is recursion?
 
Parsing Contexts for PetitParser
Parsing Contexts for PetitParserParsing Contexts for PetitParser
Parsing Contexts for PetitParser
 
Php
PhpPhp
Php
 
Macro6
Macro6Macro6
Macro6
 
The Ring programming language version 1.3 book - Part 12 of 88
The Ring programming language version 1.3 book - Part 12 of 88The Ring programming language version 1.3 book - Part 12 of 88
The Ring programming language version 1.3 book - Part 12 of 88
 

Viewers also liked

Viewers also liked (19)

Oop cocepts
Oop coceptsOop cocepts
Oop cocepts
 
Inheritance
InheritanceInheritance
Inheritance
 
Baabtra.com little coder chapter - 4
Baabtra.com little coder   chapter - 4Baabtra.com little coder   chapter - 4
Baabtra.com little coder chapter - 4
 
Transaction
TransactionTransaction
Transaction
 
Hiring in startups - What you should know.
Hiring in startups - What you should know. Hiring in startups - What you should know.
Hiring in startups - What you should know.
 
Jquery
JqueryJquery
Jquery
 
Baabtra.com little coder chapter - 3
Baabtra.com little coder   chapter - 3Baabtra.com little coder   chapter - 3
Baabtra.com little coder chapter - 3
 
Code optimization
Code optimization Code optimization
Code optimization
 
Database and types of database
Database and types of databaseDatabase and types of database
Database and types of database
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Oop concepts in python
Oop concepts in pythonOop concepts in python
Oop concepts in python
 
Functions with heap and stack
Functions with heap and stackFunctions with heap and stack
Functions with heap and stack
 
Strctures,strings,pointers
Strctures,strings,pointersStrctures,strings,pointers
Strctures,strings,pointers
 
What is Android
What is AndroidWhat is Android
What is Android
 
Introduction to mysql part 2
Introduction to mysql part 2Introduction to mysql part 2
Introduction to mysql part 2
 
Brain computer interface(neethu,bincy,sanooja)
Brain computer interface(neethu,bincy,sanooja)Brain computer interface(neethu,bincy,sanooja)
Brain computer interface(neethu,bincy,sanooja)
 
Preprocessor
PreprocessorPreprocessor
Preprocessor
 
Cell phone jammer
Cell phone jammerCell phone jammer
Cell phone jammer
 
Chapter 1 : Uses of Computer
Chapter  1 : Uses of ComputerChapter  1 : Uses of Computer
Chapter 1 : Uses of Computer
 

Similar to Baabtra.com little coder chapter - 6

Notes2
Notes2Notes2
Notes2
hccit
 

Similar to Baabtra.com little coder chapter - 6 (20)

Python unit 2 M.sc cs
Python unit 2 M.sc csPython unit 2 M.sc cs
Python unit 2 M.sc cs
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
 
python 34💭.pdf
python 34💭.pdfpython 34💭.pdf
python 34💭.pdf
 
Python programing
Python programingPython programing
Python programing
 
Notes2
Notes2Notes2
Notes2
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptx
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)
 
Php + my sql
Php + my sqlPhp + my sql
Php + my sql
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and Selection
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
 
Word embeddings as a service - PyData NYC 2015
Word embeddings as a service -  PyData NYC 2015Word embeddings as a service -  PyData NYC 2015
Word embeddings as a service - PyData NYC 2015
 
Loops in Python.pptx
Loops in Python.pptxLoops in Python.pptx
Loops in Python.pptx
 
Pythonlearn-03-Conditional.pptx
Pythonlearn-03-Conditional.pptxPythonlearn-03-Conditional.pptx
Pythonlearn-03-Conditional.pptx
 
Python Math Concepts Book
Python Math Concepts BookPython Math Concepts Book
Python Math Concepts Book
 
02 - Prepcode
02 - Prepcode02 - Prepcode
02 - Prepcode
 
Python
PythonPython
Python
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 Minutes
 
Java loops for, while and do...while
Java loops   for, while and do...whileJava loops   for, while and do...while
Java loops for, while and do...while
 

More from baabtra.com - No. 1 supplier of quality freshers

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 
Baabtra soft skills
Baabtra soft skillsBaabtra soft skills
Baabtra soft skills
 

Recently uploaded

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Recently uploaded (20)

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 

Baabtra.com little coder chapter - 6

  • 2. What you’ve learned? How to compare conditions using if statements What is block statements and importance of keeping equal spacing for block statements How to give else conditions How to nest more than one If and else conditions How to give multiple conditions inside the same if condition
  • 4. Back to Anna ! • Do you remember this particular pink color block that you’ve used for anna? • We’ve used it whenever we wanted Anna to perform the same instruction repeatedly. Similarly in python we use loops to repeat some particular instructions
  • 5. Loops • That is, whenever you want a computer to repeat something over and over again a loop instruction can be used. A loop is used to make a computer do something more than one time.
  • 6. Why Loops? • Nothing is worse than having to do the same thing over and over again. For example To print hello five times in Python, you could do the following: >>> print("hello") hello >>> print("hello") hello >>> print("hello") hello >>> print("hello") hello >>> print("hello") hello
  • 7. “It’s not tideous !! Rather we can try with loop as below which is much neater” >>> for x in range(0, 5): print('hello') hello hello hello hello hello
  • 8. “It’s not tideous !! Rather we can try with loop as below which is much neater” >>> for x in range(0, 5): print('hello') hello hello hello hello hello The range function can be used to create a list of numbers with in a range For example >>>print(list(range(10, 20))) [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
  • 9. Example >>> for x in range(0, 5): print('hello %s' % x)
  • 10. Example >>> for x in range(0, 5): print('hello %s' % x) Range(0,5) will return a list of numbers from 0 to 5 as below [0,1,2,3,4,5]
  • 11. Example >>> for x in range(0, 5): print('hello %s' % x) [0,1,2,3,4,5] x x is a variable which will have value 0 when the loop executes for the first time.
  • 12. Example >>> for x in range(0, 5): print('hello %s' % x) [0,1,2,3,4,5] x Output hello 0 1st Iteration
  • 13. Example >>> for x in range(0, 5): print('hello %s' % x) [0,1,2,3,4,5] x Output hello 0 hello 1 2nd Iteration
  • 14. Example >>> for x in range(0, 5): print('hello %s' % x) [0,1,2,3,4,5] x Output hello 0 hello 1 hello 2 3rd Iteration
  • 15. Example >>> for x in range(0, 5): print('hello %s' % x) [0,1,2,3,4,5] x Output hello 0 hello 1 hello 2 hello 3 4th Iteration
  • 16. Example >>> for x in range(0, 5): print('hello %s' % x) [0,1,2,3,4,5] x Output hello 0 hello 1 hello 2 hello 3 hello 4 5th Iteration
  • 17. Example >>> for x in range(0, 5): print('hello %s' % x) [0,1,2,3,4,5] x Output hello 0 hello 1 hello 2 hello 3 hello 4 hello 5 6th Iteration
  • 18. Loop with lists Fruits=[‘orange’,’apple’,’grape’,’pappaya’,’banana’] for i in fruits: print(i) Here we have created a list variable named fruits
  • 19. Loop with lists Fruits=[‘orange’,’apple’,’grape’,’pappaya’,’banana’] for i in fruits: print(i) Now we are using the variable fruits instead of calling range() function.
  • 20. Loop with lists Fruits=[‘orange’,’apple’,’grape’,’pappaya’,’banana’] for i in fruits: print(i) Output Orange Apple Grape Pappaya banana
  • 22. While loop • A for loop isn’t the only kind of loop you can make in Python. There’s also the while loop. A for loop is a loop of a specific length, whereas a while loop is a loop that is used when you don’t know ahead of time when it needs to stop looping. >>> x = 45 >>> y = 80 >>> while x < 50 and y < 100: x = x + 1 y = y + 1 print(x, y)
  • 24. Exercise ! • Print all the numbers between 350 and 450 using for loop • Print all the even numbers below 100 using while loop • Print all the odd numbers between 100 and 200 using while loop