Python Náhodná metoda getrandbits().
Příklad
Vraťte 8bitové celé číslo:
import random
print(random.getrandbits(8))
Definice a použití
Metoda getrandbits()
vrací celé číslo v zadané velikosti (v bitech).
Syntax
random.getrandbits(n)
Hodnoty parametrů
Parameter | Description |
---|---|
n | Required. A number specifying the size, in bits, of the returned integer. |