Sunday, March 4, 2018

Number randrange() Method


Number randrange() Method in Python 3:

Description
The randrange() method returns a randomly selected element from range(start, stop,
step).

Syntax
Following is the syntax for the randrange() method

import random
randrange ([start,] stop [,step])

Note: This function is not accessible directly, so we need to import the random module and then we need to call this function using the random static object.

Parameters
· start - Start point of the range. This would be included in the range.Default is 0.
· stop - Stop point of the range. This would be excluded from the range.
· step - Value with which number is incremented. Default is 1.

Return Value
This method returns a random item from the given range.
Example
The following example shows the usage of the randrange() method.




When we run the above program, it produces the following