# ---------------------------------------------------------- # HW 9 # ---------------------------------------------------------- # Please answer these questions after having completed the # entire assignment. # ---------------------------------------------------------- # Name: # Hours spent in total: # Collaborators (if any) and resources used (if any): # Feedback: What was the hardest part of this assignment? # # Feedback: Any suggestions for improving the assignment? # # ---------------------------------------------------------- import random def printGallows(num_missed): ''' (int) -> None Print a representation of the hangperson gallows. The parameter to the function is the number of missed words. 7 misses means that the player has lost (and the full gallows gets printed). ''' if (num_missed < 0 or num_missed > 7): raise Exception("Invalid number of missed words when attempting to print the gallows.") print print print ' |||========|||' if num_missed > 0: print ' ||| |' else: print ' ||| ' if num_missed > 1: print ' ||| O' else: print ' ||| ' if num_missed > 2: if num_missed > 4: print ' ||| /|\\' elif num_missed > 3: print ' ||| /| ' else: print ' ||| / ' else: print ' ||| ' if num_missed > 5: if num_missed > 6: print ' ||| / \\' else: print ' ||| / ' else: print ' ||| ' print ' |||' print ' |||' print ' =================' print # # define helper functions here. # def play_game(): # our list of possible words. add or modify the # list as you want wordlist = ['SUNNY','BEES','GRASS','BUNNY'] # example for getting a random word from the word list secretword = random.choice(wordlist) # # fill in the rest of this function # def main(): # play a single game of hangperson # then ask the user if they want to play again main()