1# generate random integer values
2from random import randint
3
4value = randint(0, 10)
5print(value)
6
1# imports random
2import random
3# randint generates a random integar between the first parameter and the second
4print(random.randint(1, 100))
1# imports random
2import random
3# randint generates a random integar between the first parameter and the second
4print(random.randint(1, 100))
5# random generates a random real number in the interval [0, 1)
6print(random.random())
1>>> n = 16
2
3>>> # Generate secure tokens
4>>> secrets.token_bytes(n)
5b'A\x8cz\xe1o\xf9!;\x8b\xf2\x80pJ\x8b\xd4\xd3'
6>>> secrets.token_hex(n)
7'9cb190491e01230ec4239cae643f286f'
8>>> secrets.token_urlsafe(n)
9'MJoi7CknFu3YN41m88SEgQ'
10
11>>> # Secure version of `random.choice()`
12>>> secrets.choice('rain')
13'a'
14