Python range() Function
Python range() function returns an immutable sequence of numbers starting from 0, increments by 1 and ends at a specified number.
- range(start, stop, step)
start (optional) : It is an integer number that specifies the starting position. The Default value is 0.
stop (optional) : It is an integer that specifies the ending position.
step (optional) : It is an integer that specifies the increment of a number. The Default value is 1.
It returns an immutable sequence of numbers starting from 0, increments by 1, and ends at a specified number.
Python range() Function Example 1
The below example shows the working of range().
# empty range
# using the range(stop)
# using the range(start, stop)
[0, 1, 2, 3]
[1, 2, 3, 4, 5, 6]
Note: In the above example, we’ve converted the range to a Python list and returned a generator-like object that only prints the output on demand.
A range object returned by the range constructor can also be accessed by its index. It can support both positive and negative indices.
Python range() Function Example 2
The below example creates a list of number between the given numbers using range() function.
start = 5
stop = 12
step = 4
print(list(range(start, stop, step)))
- [5, 9]
Recently Trained Students
My instructor had sound Knowledge and used to puts a lot of effort that made the course as simple and easy as possible. I was aiming for with the help of the ZebLearn Online training imparted to me by this organization.
I got my training from Zeblearn in the Python Certification Training, I would like to say that say he is one of the best trainers. He has not even trained me but also motivated me to explore more and the way he executed the project, in the end, was mind-blowing.
Candidate’s Journey During Our Training Program
Expert’s Advice & Selection of Module
Choosing the right type of module for the training is half the battle & Our Team of experts will help & guide you.
Get Trained & Learn End to End Implementation from our Expert Trainer who are working on the same domain.
Work on Projects
We Do make our student’s work on multiple case studies , scenario based tasks & projects in order to provide real-time exposure to them.
We have a dedicated placement cell in order to provide placement assistance & relevant interviews to our candididates till selection