Home >>Python Random Module >Python Random getrandbits() Method

Python Random getrandbits() Method

Python Random getrandbits() Method

Python Random getrandbits() Method in python is used to returns an integer in the specified bits (size).

Syntax:
random.getrandbits(n)

Parameter Values

Parameter Description
n It is Required a number to specified the size, in bits.
Here is an example of Python Random getrandbits() Method:

import random
print(random.getrandbits(12))

Output:
968
Example 2:

import random
print(random.getrandbits(15))

Output:
19490

No Sidebar ads