Python range() function in python-range of int

Spread the love
Hello everyone, Today we will learn with the help of different example how to use Python’s range() functions. range() function is in built function in python.I t is generatesd the integer number between the  start to the stop integers means it return the object.
It is used when a users also need to perform an action for a  specific numbers of time. The range() functions is used to generate a sequence of number and char..
range() is used in for loop function and  hence, knowledge of same is keys be aspect.

What Python range() Basics ?

In simple way , range() function allow user to generate a series of number within a given specific range. Depending on how many argument user is passing to the functions in it. user can decided big the difference will be between one numbers and the next format.PYTHON
range() take mainly three arguments this are following :
  • start:  starting integer from which the sequence of integer is to be returned the value.
  • stop: before integer The range of integers end at stop – 1.integer which the sequence of integers is to be returned the values
  • step: value of integer which determine the increments between integer in the sequence
print(“Python range() example value:”)
print(“input numbers from range 0 to 4”)
for i in range(4):
print(i, end=‘, ‘)
Python range() example value:

input numbers from range 0 to 6

0, 1, 2, 3

Some range() function syntax and argument in python:

It contains three arguments. Out of this three 2 arguments are start and step are the optional arguments.
  1. start argument is a starting numbers of the sequence. it start with lower limit. By default, it starts with 0 number.
  2. stop argument is an like as uppers limit.The range() doesn’t include this numbers in the result format.
  3. step argument is a difference between each number in the search resures. The default value of the step is 1and  if it not specified values.

 Some range() function Examples give below:

Let see all the possible probability now. Below are the three value of range() functions.
Example one – Using only one arguments:
# Print first starting 8 numbers using range python function
for i in range(5):
print(i, end=‘, ‘)
0, 1, 2, 3, 4, 5, 6, 7
Only a stop arguments can be passed to range() . So by default, it taken start = 0 and step = 1. Values
Example Two – using two arguments functions(means: start and stop)
# Print integers value within given starting and ending number using range()
for i in range(2, 7):
print(i, end=‘, ‘)
2, 3, 4, 5, 6

Example Three – using all three arguments run the code:
# We use start, stop, and step arguments in range() function
print(“Show the All even numbers between 6 to 15 using range() functions in python”)
for i in range(6, 15, 6):
print(i, end=‘, ‘)
Show the All even numbers between 6 to 15 using range() functions in python

6, 8, 10, 12, 14
# Write Python programs to

# print whole value numbers

# using range() functions

# whole numbers value

# printing first 5
print(i, end =” “)

for i in range(5): 

for i in range(13):

# printing first 13 number 
# whole numbers 
print(i, end = ” “)
0, 1, 2, 3, 4

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12

Some Point to always remembering about range() function argument:

  • range() can be only work with the integer number. And all argument in python must be integer value. You can’t use float numbers or any other types in a starting, stopped and step argument of a range() Functions.
  • All this three argument can be positive or negative no matter.
  • The step values can’t be zero. If a step values is zero then Python give or generates a ValueError exception.
Some FAQ about Python range() :
1. What is the range in Python?
Python range() function return the sequence of number, and it start from 0 by default, and increments by with 1 , then stop before a specified numbers.
2. What is the range of int in Python?
int represent number in the range from -214748365 to 214748365. 
3. How do you find the range in Python?
Points must be always remember about Python range() functions :

range() function always work with the integer or whole number. arguments always must be integer. User can’t pass a strings or float numbers in a start, stop and step arguments in python range() function.


python range() function in python
fig 01) python range() function
Tags: Python range() function in python,What is the range in Python?,What is the range of int in Python?,How do you find the range in Python?
If you want to learn python crash course for free then click on python tutorials point. If you like this post then please comment and share.

sachin Pagar

I am Mr. Sachin pagar Embedded software engineer, the founder of Sach Educational Support(Pythonslearning), a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Leave a Reply