import random
#1.A single element
random.choice(list)#2.Multiple elements with replacement
random.choices(list, k =4)#3.Multiple elements without replacement
random.sample(list,4)
import random
sequence =[i for i inrange(20)]
subset = random.sample(sequence,5)#5 is the lenth of the sampleprint(subset)# prints 5 random numbers from sequence (without replacement)
import random
# with replacement = same item CAN be chosen more than once.# without replacement = same item CANNOT be chosen more then once.# Randomly select 2 elements from list without replacement and return a list
random.sample(list_name,2)# Randomly select 3 elements from list with replacement and return a list
random.choices(set_name, k=3)# Returns 1 random element from list
random.choice(list_name)
animal =["monkey","cat","goat","cow","horse","snake","dog"]
randomlst =[]
n =len(animal)for i in random.sample(range(0,n),n):
randomlst.append(animal[i])print(randomlst)