import random functions Flashcards

1
Q

function to generate a random number given a range

A

x = random.randint(1,6)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

functon to create a random floating point decimal <1

A

y= random.random()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

function to randomly pick a item out of a list

A

mylist= [‘rock’,’paper’,’scissors’]
z = random.choice(mylist)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly