In this tutorial we will talk about the built in function in Python range the range function generate
integer numbers between the given start integer and stop integer and using a for loop begin I iterate
or what.
These generated integers and this is the syntax for D range function out of the three arguments start
stop and step dad and step add optional argument and they start argument is a starting number of the
sequence that does the lower element by default.
It starts with 0.
If it does not specify this top argument this top argument is the upper limit that is generate numbers
up to this number.
Then the range function does not include this number in the result.
The step argument is a difference between each number in the result and the default value of step is
1.
If it does not specify so using a for loop we are going to iterate over the numbers generated using
this range function.
The lower limit that that is the start argument is 1.
So the sequence starts with this number and the upper limit.
These top.
Argument is 10 and the resultant output does not include the stop argument and the step argument is
2.
That means the difference between between each number in the output should be 2.
Now we are going to use a for loop to iterate or what the numbers generated using the range function
and let and then print the number.
So let's execute this piece of code.
As you can see the numbers have been generated from the starting argument up until number 9 integer
9 excluding these top arguments.
For example you want to print the sequence of numbers in the reverse order using the range function
or you want to print the sequence of numbers in the descending order.
In that case in that case say for example your starting argument you start argument is 10 and you want
to print numbers up until 2.
So the stop argument should be 1 and because you want to print the numbers in that it was ordered.
Thus difference between each number and the result should be minus 1 in the descending order.
So let's execute this piece of code.
So here you have the numbers printed in that he was ordered.
The python range function returns an immutable sequence object of integer so it is possible to convert
the output of the change function to a Python list.
So in order to do this we have to parse the range object to the list function.
So let's see how this can be done.
Let's say we are going to create list 1 and we need to parse the range object to the list function.
Convert the output of the range function to a Python list.
So in order to do that let's call the range function and say we're going to pass the stop and the start
and this top argument is 1 and 10 and then execute.
And when you display the list 1 The Range object has been converted to a list.