For Loop Statements in Python 3

DDSRY
2 min readMay 10, 2020

What if someone tells you to print number on PC screen from one to 100
OR if someone tells you to print your name 100 times on the computer screen.

if you will use a print() function to print numbers from 1–100 then,
it will consume more time as well as increase the number of lines in your
code.

For Loops in Python 3

Python provides us with an efficient way to do the same thing that's called
LOOPs.
▪️ Loops are used to execute a statement multiple times.
▪️ Loops are used to Repeat task.

There are 2 types of loops in Python :

▪️For Loops
▪️While Loops

FOR LOOPs :

▪️A for loop repeats over a given sequence.

▪️for a variable in sequence:
statements

▪️after for keyword variable name should be there
▪️ where variable refers to a counter variable.
▪️ and sequence contains the data over which looping needs to be done.
▪️ after the variable name, there should be a condition/data which looping needs to be done.

▪️ For example:

for loops statements in python version 3 | DDSRY | python programming language | learn Python | python tutorial

for num in range(1,10):
print(num)

▪️ The above code will print numbers from 1 to 9 because of loop print the
1 less number than the given number.
▪️ range() is a built-in function in python.
▪️ range() takes a starting value and an ending value.
▪️ if we will use range(10) then it will start from 0 to 9
▪️ if we will use range(1,10) then it will start from 1 to 9

Follow on Instagram to learn Python:

--

--