Spread the love

Table of Contents

__Python range() function__

__Python range() function__

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 ?

__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=‘, ‘)

` `

Output:

Python range() example value:

input numbers from range 0 to 6

0, 1, 2, 3

__Some range() function syntax and argument in python:__

__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.

- A start argument is a starting numbers of the sequence. it start with lower limit. By default, it starts with 0 number.
- A stop argument is an like as uppers limit.The
`range()`

doesn’t include this numbers in the result format. - A 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:__

__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:

for i in range(5):

` `

print(i, end=‘, ‘)

` `

Output:

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`

. ValuesExample 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=‘, ‘)

` `

Output:

2, 3, 4, 5, 6

# 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=‘, ‘)

` `

Output:

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):
print()
```

for i in range(13):

```
# printing first 13 number
# whole numbers
```

print(i, end = ” “)

` `

**Output:**

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.

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.

BEST OF LUCK!!!