0% found this document useful (0 votes)
1 views

Random Module One Pager by Nitin Paliwal

The Python random module is used to generate pseudo-random numbers and perform random operations, including generating random floats and selecting random items from sequences. Key functions include random() for generating floats, randint(a, b) for integers within a range, and randrange(start, stop[, step]) for selecting elements from a specified range. Examples illustrate the usage of these functions in generating random values.

Uploaded by

yaswanth270308
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Random Module One Pager by Nitin Paliwal

The Python random module is used to generate pseudo-random numbers and perform random operations, including generating random floats and selecting random items from sequences. Key functions include random() for generating floats, randint(a, b) for integers within a range, and randrange(start, stop[, step]) for selecting elements from a specified range. Examples illustrate the usage of these functions in generating random values.

Uploaded by

yaswanth270308
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#MAHARATHI MATERIAL BY NITIN PALIWAL | CLASS 12 COMPUTER SCIENCE

Random Module ONE PAGER

INTRODUCTION
The Python random module provides func ons to generate pseudo-random
numbers and perform random opera ons. It’s widely used for:
 Genera ng random numbers (floats and integers).
 Selec ng random items from sequences.

Key Func ons of the Random Module

Func on Descrip on Return / Effect


random() Returns a random float in the range Float
(0.0, 1.0).
(1 is exclusive)
randint(a, b) Returns a random integer N such that Integer
a <= N <= b.
(stop is inclusive)
randrange(start, Returns a randomly selected element Integer
stop[, step]) from range(start, stop, step).
(stop is exclusive)

Examples and Use Cases


Func on Example Code Explana on
random() random.random() Generates a random float
between 0.0 and 1.0.
(1 exclusive)
randint(a, b) random.randint(1, 10) Returns a random integer
between 1 and 10.
randrange(start, random.randrange(0, 20, 2) Returns a random even
stop, step) number from 0 to 18.

You might also like