Mastery 24 Creation and use of ranges in Python

in this mastery I will write about function range. first what does it do? it generates a list of numbers, which is generally used to iterate over with for loops.

function has two sets of parameters, as follows:

range(stop)

wich it will print numbers beginig from zero to (stop-1). For example:

range(4) == [0,1,2,3]

the other parameters is:

range(start,stop,step)

>start it means in wich number it will start

>stop it means  when is going to stop but like this(stop-1)

>step it means the difference between each number in the sequence

examples of using range:

1.-range(0,11,2) == [0,2,4,6,8,10]

2.-range(3,9)==[3,4,5,6,7,8]

this is a link that its very helpful to understand : http://www.pythoncentral.io/pythons-range-function-explained/

CC BY 4.0 Mastery 24 Creation and use of ranges in Python by Efrain Duarte is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.