1# imports random
2import random
3# randint generates a random integar between the first parameter and the second
4print(random.randint(1, 100))
1#import random
2import random
3
4names = ['Harry', 'John', 'Smith', 'Larry']
5
6#print random name from names
7print(random.choice(names))
8
9#print random integer in a range of numbers
10print(random.randint(1, 100)
1# imports random
2import random
3# randint generates a random integar between the first parameter and the second
4print(random.randint(1, 100))
5# random generates a random real number in the interval [0, 1)
6print(random.random())
1import random
2
3#sampling with replacement
4list = [20, 30, 40, 50 ,60, 70, 80]
5sampling = random.choices(list, k=4)
6print("Randomly selected multiple choices using random.choices() ", sampling)
1# returns randomized k values from a list, tuple, set
2# import random
3import random
4# return 10 random values from list my_list
5random_values = random.sample(my_list, 10)