# Random Number Generation¶

This module is based upon the `random` module in the Python standard library. It contains functions for generating random behaviour.

To access this module you need to:

```import random
```

We assume you have done this for the examples below.

## Functions¶

`random.``getrandbits`(n)

Returns an integer with `n` random bits.

Warning

Because the underlying generator function returns at most 30 bits, `n` may only be a value between 1-30 (inclusive).

`random.``seed`(n)

Initialize the random number generator with a known integer `n`. This will give you reproducibly deterministic randomness from a given starting state (`n`).

`random.``randint`(a, b)

Return a random integer `N` such that `a <= N <= b`. Alias for `randrange(a, b+1)`.

`random.``randrange`(stop)

Return a randomly selected integer between zero and up to (but not including) `stop`.

`random.``randrange`(start, stop)

Return a randomly selected integer from `range(start, stop)`.

`random.``randrange`(start, stop, step)

Return a randomly selected element from `range(start, stop, step)`.

`random.``choice`(seq)

Return a random element from the non-empty sequence `seq`. If `seq` is empty, raises `IndexError`.

`random.``random`()

Return the next random floating point number in the range [0.0, 1.0)

`random.``uniform`(a, b)

Return a random floating point number `N` such that `a <= N <= b` for `a <= b` and `b <= N <= a` for `b < a`.