In this exercise you will practice
You like word-guessing games.
Write a Python program in a file named hangman.py
that implements the classic Hangman game. Game play proceeds as follows:
As long as the hangman is not complete or the user has not guessed all the letters in the word:
Your program should use two provided modules:
hangfig
, which draws the parts of a typical hangman figure using turtle graphics andhangwords
, which contains words from two categories – easy and hard – in a dictionary of lists.A finished hangman program will look something like this:
parts = [hangfig.head, hangfig.body]
and call hangfig.head
with parts[0]()
.range()
function returns an interator over a range of integers. For example, if you have a list of elements, xs
, range(len(xs))
returns an iterator over the indexes of xs
. See built-in functions docs.random
module’s choice(seq)
function returns a randomly chosen element from seq
. See random module docs.input()
function. Otherwise the turtle window with the hangman will disappear immediately.Extend your hangman program by writing thee additional Python files (in your hangman
directory) and integrating their content into your hangman program:
extraparts.py
– a module that draws additional body parts on the hangman drawn by hangfig.py. These can be facial features, hands, feet, or any creative non-lewd idea of your own.extrawords.py
– a module containing additional word lists, named by type of word. Again, use your creativity.