python random number between min and max value (both inclusive)
Python[Edit]
+
0
-
0
python random number between min and max value (both inclusive)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29import math import random # inclusive min, inclusive max def random_number(minimum, maximum): return math.floor(random() * (maximum - minimum + 1) + minimum) # Usage example: print(randomNumber(0, 3)) print(randomNumber(0, 3)) print(randomNumber(0, 3)) print(randomNumber(0, 3)) print(randomNumber(0, 3)) # Example output: # # 1 # 0 # 2 # 3 # 3 # See also: # # 1. https://dirask.com/snippets/Python-random-integer-Ddkeo1