how to print number series in python with the use of for loop for beginners. | learn python for free with examples for beginners.
Story: FOR LOOP IN PYTHON FOR BEGINNERS ; 06-09-2023;
how to print number series in python with the use of for loop for beginners. | learn python for free with examples for beginners.
for variable_name in sequence: statements
for mak in range(10):
print(mak)
OP: 0 1 2 3 4 5 6 7 8 9
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.
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
Follow us on social media (we post updates with a link) at @dedaandsonsl.