0% found this document useful (0 votes)
2 views5 pages

Random Module

The Random module in Python is a built-in module used for generating random numbers, selecting random elements from lists, and reshuffling strings. Key functions include random(), randrange(), and randint(), each serving different purposes for generating floating-point numbers and integers within specified ranges. The module allows for versatile random number generation with simple syntax.

Uploaded by

pinterestyyaazh
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)
2 views5 pages

Random Module

The Random module in Python is a built-in module used for generating random numbers, selecting random elements from lists, and reshuffling strings. Key functions include random(), randrange(), and randint(), each serving different purposes for generating floating-point numbers and integers within specified ranges. The module allows for versatile random number generation with simple syntax.

Uploaded by

pinterestyyaazh
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

Random module

random()
randrange()
randint()
choice()
uniform()
shuffle()
Random Module:
It is a build-in module in python
It will use generate the random numbers.
It can choose the random element from the list.
It can reshuffle the string.
It can also generate the floating point numbers.

Syntax:
import random
random()
• This will generate floating values between 0 and 1 (including 0 but
excluding 1).It does not require any argument.

• Synatx: [Link]()
randrange()
• This method always return an integer between given lower and upper
limit (excluding upper limit).
Syntax:
[Link](20)
#It will generate random integers between 0,19
[Link](0,6,2)
# It will generate random value 0,2,4
randint()
This method takes two arguments a,b in which first is lower limit and
second one is upper limit.
This function will return any integer number between the two number
including both limits.
[Link](1,6)
# It will generate random value 1,2,3,4,5,6

You might also like