If you see this, something is wrong
First published on Monday, Feb 23, 2026 and last modified on Monday, Feb 23, 2026
Sequential Loops for
We continue our programming topics with the sequential loops for.
We first use the range lists and then the arange arrays of NumPy.
We first see the loops for with the range lists.
Launch Anaconda and Spyder and follow me.
Let's define the list l.
as the range of 10.
l=range(10)The first index l of 0, 0 into brackets, it is 0.
l[0]And l of 10, 10 into brackets, it is not defined. There is no element of index 10.
l[10]And l of 9, it is 9.
l[9]Now let's use a loop for, to see all the elements in range of 11.
for i in range of 11, because we want all the numbers up to 10.
Double point, return.
print, parenthesis, i parenthesis.
And we have all the integers from 0 to 10.
for i in range(11):
print(i)So we can see that in the range of 11, we have the integers from 0 to 10.
11 is not included.
Now we shall explore the range statement.
We add a 1 before the 11, 1 comma 11, and it gives the integers from 1 to 10.
for i in range(1,11):
print(i)0, 11, 11, 2.
2 is a step.
It gives the even numbers from 0 to 10.
This is because it is the integers from 0 to 10 by steps of 2.
for i in range(0,11,2):
print(i)Now we shall start from 11 and go down to 2 by steps of -1, a negative number.
And we have all the integers from 11 down to 3, and not 2 because 2 is not included.
for i in range(11,2,-1):
print(i)Now we shall see the sequential loops for, with the arange arrays from NumPy.
Launch Anaconda and Spyder and follow me.
We first type 'from numpy import *', in order to have the arange function available.
from numpy import *And now we print arange of 10.
And we have a vector into brackets of the integers from 0 to 9.
print(arange(10))print arange of 1 to 11.
We have the integers from 1 to 10.
print(arange(1,11))From 10 to 0 by steps of -1.
We have the numbers from 10 down to 1.
print(arange(11,0,-1))If we want to have 0 at the end, we must go down to -1.
print(arange(11,-1,-1))And arange is also possible with non-integers.
-1, from -1, to 1 by steps of 0.1.
And we have decimal numbers with the exponential notation.
print(arange(-1,1,0.1))Now we shall make a for loop in order to display the multiples of the numbers from 1 to 5.
for n in arange of 1 comma 6 double point.
We have to go up to 6 in order to have the numbers from 1 to 5.
print n multiplied by the arange (it is possible to make an element by element multiplication with NumPy) arange of 1 comma 6, the numbers from 1 to 5.
for n in arange(6):
print(n*arange(6))We have in the first line the numbers from 1 to 5 multiplied by 1, in the second line, multiplied by two, etc. until the fifth line, multiplied by five.
What's coming now? What's coming now is the graphics in Python, with MatPlotLib package.