Learn Dedaandsons

Story: FOR LOOP IN PYTHON FOR BEGINNERS ; 06-09-2023;

Python: for loop with syntex and easy example of 0 to 9 number series.

how to print number series in python with the use of for loop for beginners. | learn python for free with examples for beginners.

Here's the syntax of the for loop in Python:

for variable_name in sequence: statements

here's an example of the for loop in python:

for mak in range(10):

print(mak)

OP: 0 1 2 3 4 5 6 7 8 9

Explanation for the program:

After defining the for loop in the first line we have used a variable called "mak" (you can choose any other name.) Learn more about variable and data types

The in keyword is used to specify the sequence that will be iterated over. The sequence can be a list, a tuple, a range, or any other iterable object. The statements block is executed for each item in the sequence. In the statements block we have used the Python print() function is an output statement.

The program will run 10 times (as given in the range), you will see a output of number series from 0 to 9.

Exercise-2:

Table generator using For Loop:

mak=input("enter number ")

for alsmr in range(1,11):

c= int(mak)*alsmr print(c)

enter number 20: 20 40 60 80 100 120 140 160 180 200

More?:

Move Back to Top

Like, share, follow us.