import random functions Flashcards
1
Q
function to generate a random number given a range
A
x = random.randint(1,6)
2
Q
functon to create a random floating point decimal <1
A
y= random.random()
3
Q
function to randomly pick a item out of a list
A
mylist= [‘rock’,’paper’,’scissors’]
z = random.choice(mylist)
4
Q
function to shuffle through a list randomly
A
cards = [1,2,3,4,5,6,7,8,9,”J”,”Q”,”K”,”A”]
random.shuffle(cards)