1# generate random integer values
2from random import randint
3
4value = randint(0, 10)
5print(value)
6
1# To create a list of random integer values:
2import random
3randomlist = random.sample(range(10, 30), 5)
4# Output:
5# [16, 19, 13, 18, 15]
6
7# To create a list of random float numbers:
8import numpy
9random_float_array = numpy.random.uniform(75.5, 125.5, 2)
10# Output:
11# [107.50697835, 123.84889979]
1# generate random integer values
2from random import seed
3from random import randint
4# seed random number generator
5seed(1)
6# generate some integers
7for _ in range(10):
8 value = randint(0, 10)
9 print(value)
10
1from random import randint
2
3print(randint(1,3))
4
5#Possible Outputs#
6#1
7#2
8#3
1from random import randint
2
3radnom_number = randint(1, 10) # generate random number from 1 to 10. including 10
4
5print(radnom_number)
6
7# Possible outputs
8# 1
9# 2
10# 3
11# 4
12# 5
13# 6
14# 7
15# 8
16# 9
17# 10