## Class 11 – Friday, September 21

## Being random for a loop

You did not expect – The repetition to come – You did not expect

### Look both ways

### Proof my two dogs are not as smart as they think they are

### Agenda

- Introduce the random module

### Examples to introduce random module

- Program thats_so_random.py

- Introduce some helpful functions from the random module.

- Program bit_by_bit.py

- Generates a list of
`n`

bits (binary digits) for a user-supplied`n`

.

- Program octane.py

- Prompts and gets three user-supplied integers
`s`

,`n`

, and`d`

. Uses integer`s`

as a seed to the Python random number generator.

- Accumulates a list of
`n`

octal digits (base 8 digits) one by one. Afterwards, prints the list of octal digits.

- Determines and prints the number of occurrences of
`d`

in the list of octals (check out the list module for a helpful function.

- Two program runs

Enter three numbers: 1112 12 1

[4, 1, 4, 0, 6, 1, 5, 2, 5, 1, 1, 2]

4

Enter three numbers: 8 9 6

[3, 5, 6, 2, 3, 0, 1, 2, 3]

1

### To do list

- Review class artifacts.

- Do the chatter.py homework.

- Check out my documentation for the
`random`

module.