4 examples of 'from random import randint' in Python

Every line of 'from random import randint' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
38def test_randomstate_randint_randomness(rnd):
39 a = rnd.randint(10000)
40 b = rnd.randint(10000)
41 assert a != b
16def randint(a, b):
17 return a + int(random.random() * (b + 1 - a))
87def randrange(start, stop=None, step=1):
88 """Choose a random item from range(start, stop[, step]).
89
90 This fixes the problem with randint() which includes the
91 endpoint; in Python this is usually not what you want.
92
93 EXAMPLES:
94 sage: randrange(0, 100, 11)
95 11
96 sage: randrange(5000, 5100)
97 5051
98 sage: [randrange(0, 2) for i in range(15)]
99 [0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1]
100 sage: randrange(0, 1000000, 1000)
101 486000
102 sage: randrange(-100, 10)
103 -56
104 """
105 return _pyrand().randrange(start, stop, step)
15def rando():
16 return random.StrongRandom().randint(2, 20000000)

Related snippets