You are on page 1of 8

Random Numbers

The “random” 1.
2.
choice()
randrange()

Library 3.
4.
random()
seed()
5. shuffle()
Functions 6. uniform()
random.choice(container)
- Generates 1 number
from a container

- If we have a list called a,


and we call
random.choice(a), it will
choose a random object
from a.
random.randrange(beg, end)
- Generates a number
within a range including
beg and excluding end

- Ex:
random.randrange(1,6)
will choose a random
number from 1-5
random.random()

- Generates a floating
point number less than 1
and greater than or equal
to 0 [0, 1)
random.seed(seed_argument)
Maps a particular random number
with the seed argument
random.shuffle(list)

- Shuffles the specified list

- If we have a list called a,


and we use
random.shuffle(a), it will
shuffle the elements in a
random.uniform(beg, end)
- Generates a floating
point number within a
range including beg and
excluding end

- Same thing as randrange


except with floats

You might also like