Important Notice:

Course Content
The Calendar Module
Library Function/Predefined Functions
0/4
Sys Module
Library Function/Predefined Functions
0/2
OS Module
Library Function/Predefined Functions
0/2
Functions in Python (Chapter-10) M3-R5
About Lesson

randrange() Method

             The randrange() method returns a randomly selected element from the specified range.

Syntax

random.randrange(start, stop, step)

Parameter

Description

start

Optional. An integer specifying at which position to start.
Default 0

stop

Required. An integer specifying at which position to end.

step

Optional. An integer specifying the incrementation.
Default 1

Example

Return a number between 3 and 9:

import random
print(random.randrange(3, 9))

#returns a number between 3 (included) and 9 (not included)

Output:

5

error: Content is protected !!