Python Random getrandbits() Method
❮ Random Methods
Example
Return an 8 bits sized integer:
import random
print(random.getrandbits(8))
Try it Yourself »
Definition and Usage
The getrandbits()
method returns an integer
in the specified size (in bits).
Syntax
Parameter Values
Parameter |
Description |
n |
Required. A number specifying the size, in bits, of the returned
integer. |
❮ Random Methods