How to use 'randint without replacement' in Python

Every line of 'randint without replacement' 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
this disclaimer
9def with_replacement(samples):
10 total = 0
11
12 for i in range(samples):
13 a = random.randint(1, 10)
14 b = random.randint(1, 10)
15 c = a + b
16 total += c
17
18 avg = total / samples
19 return avg
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code


Related snippets