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
1#to choose a random number simply do this
2import random
3print(random.randint(1, 100))
1# We'll be using the random module for this code
2import random
3# Let's first get the range of numbers from which they want a random number
4start = int(input('What is the lowest number you would expect'))
5end = int(input('What is the largest number you would expect'))
6print('This is the number',random.randint(start,end))