Generate A Random Integer In Python

October 2020

This code will generate a random number

from random import randint

random_num = randint(0, 10)
print(random_num)
Output:
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)

TODO

    Make and link to a post with random floats

end of line