Introspection

Warming up

Try the following on the interactive shell:

import random
dir(random)
help(random.choice)
name = random.choice(['Hannah', 'Emily', 'Sarah'])
type(name)

What does the code do?

The Challenge: a Baby name generator

Write a program that will generate a random baby name from a list of possible names.

Use the Python module random

Extra challenges:

  • let the user choose the gender of the babies.
  • let the user enter how many babies they want to have.
  • load baby names from a file.

results matching ""

    No results matching ""