Generate A Random Integer In Python

This code will generate a random number

Code
from random import randint

random_num = randint(0, 10)
print(random_num)
Results
0
Notes
  • Gives numbers between 0 and 10 (inclusive of both 0 and 10)

  • It's possilbe to set a specific seed which will always produce the same numbers (which I've found useful for testing)