1# generate random integer values
2from random import randint
3
4value = randint(0, 10)
5print(value)
6
1# imports random
2import random
3# randint generates a random integar between the first parameter and the second
4print(random.randint(1, 100))
1#imports
2import random
3#randint generates a random number between the first set and the second set of parameters
4x = random.randint(1, 100)
5print(x)
1#Using Random choice python
2#Running Race game
3import time
4import random
5gamelist = ['You lose the race', 'You win the race']
6Player = input('')
7print(' Hi ' + Player + ' , welcome to the running race game')
8time.sleep(2)
9print('3')
10time.sleep(1)
11print('2')
12time.sleep(1)
13print('1')
14time.sleep(2)
15print(random.choice(gamelist))
16
1>>> random.randrange(1, 10)
22
3>>> random.randrange(1, 10, 2)
45
5>>> random.randrange(0, 101, 10)
680
7