Save
PL 11-12
Save
Share
Learn
Content
Leaderboard
Learn
Created by
Jeff
Visit profile
Subdecks (3)
PL MOD 15
PL 11-12
7 cards
PL MOD 14
PL 11-12
9 cards
PL MOD 13
PL 11-12
6 cards
Cards (37)
2 types of loops in Python:
for loop
while loop
the
for loop
is used to run a block of code for a certain number of times.
loops
are used to repeat a block of code.
A
range
is a series of values between two numeric intervals.
a for loop inside another for loop, it’s called a
nested for loop.
The
break statement
is used to exit the for loop prematurely.
We can use
continue statements
inside a for loop to skip the execution of the for loop body for a specific condition.
step parameter
- It tells the range function how many numbers to skip between each count.
A
while loop
implements the repeated execution of code based on a given Boolean condition.
The syntax of
while loop
The syntax of the
for loop
We can use
else block
with a Python for loop.
A while loop can have an optional
else block
as well.
str.lower()
- a string function to convert the string to all lower-case
It is used to iterate over any sequences such as
list
,
tuple
,
string
See all 37 cards