Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help coding a game of hangman using python. Introduction This assignment is not as hard or long as it may seem, so do

I need help coding a game of hangman using python. image text in transcribed
image text in transcribed
image text in transcribed
Introduction This assignment is not as hard or long as it may seem, so do not despair. The description will be much longar than your code. We have provided you with some of the basic parts of the program, and you have to firish some incomplete functions You will create a variation of the cdassic word game "Hangman". For those of you who are unfamiliar with the rules, they are explained at http://en.wikipedia.org/wiki /HangmanC20%28gane%29. In the version we will implementthe computer always picks a word at random. and the human player will try so guess the word You will implement a function, named hangman, that will carry out an interadtive Hangman game between a player and the computer. Before we get to this function, we'll first implement a few helper functions you will moed. For this problem, you will need the code ile a2 hangsan.py and the dictionary of woeds words.txt Be sure to save the files in the same directory. Open and run the ile a2 hangsan-py without making any modifications to it, in order to ensure that everything is set up correctly. In other words, you should do the folowing Load IDLE. Frana the File menu, choose "Open. Find thee a2Lhangnan, py and chose it. The template a2 hangman.py should now be open Run the file. The code we have given you loads in a list of words from a file. If everything is working okay, after a small delay, you should see the following messages nin ansagnment is adapted from one used in the MrTx 60.1s course. Loading word list from file 55969 words loaded. If you see an error instead sxh "No such file or directory.), you may need to change the value of the WORDLIST FILENAME constant (defined near the top of the file) to the complete pathname for the tile words.txt (This will vary based on where you saved the file). The file a2 hangman.py aeady comains three functions functions you will use in your solution You can ignore the details of the code between the fol lowing commeets, though you should read the doctrings so that you undersand how to use each function. # Helper code # You don't need to understand this helper code #but you will have to know how to use the functions # (so be sure to read the docstrings!) (end of helper code) You must do all of your coding for this proklem entirely within this file, because you will be writing a program that depends on cach function you write Requirements Here are the requirements for the game: 1. The compater will select a word a random from a list of available words that was peovided in words.Ext. The functions for loading the word list and selecting a random wond have already been provided for you in a2 hangman-py 2. The game must be interactive; the flow of the game should go as follows: At the start of the game, let the player know how many leters the computer's word contains . Ask the player to supply one gurss (ie. leter) per turn . The player should receive feedback immediately after each guess about whether their guess appears in the computer's word . After each turn, you should also print the partially puessed word as well as the list of letters that the player has not yet guessed. Introduction This assignment is not as hard or long as it may seem, so do not despair. The description will be much longar than your code. We have provided you with some of the basic parts of the program, and you have to firish some incomplete functions You will create a variation of the cdassic word game "Hangman". For those of you who are unfamiliar with the rules, they are explained at http://en.wikipedia.org/wiki /HangmanC20%28gane%29. In the version we will implementthe computer always picks a word at random. and the human player will try so guess the word You will implement a function, named hangman, that will carry out an interadtive Hangman game between a player and the computer. Before we get to this function, we'll first implement a few helper functions you will moed. For this problem, you will need the code ile a2 hangsan.py and the dictionary of woeds words.txt Be sure to save the files in the same directory. Open and run the ile a2 hangsan-py without making any modifications to it, in order to ensure that everything is set up correctly. In other words, you should do the folowing Load IDLE. Frana the File menu, choose "Open. Find thee a2Lhangnan, py and chose it. The template a2 hangman.py should now be open Run the file. The code we have given you loads in a list of words from a file. If everything is working okay, after a small delay, you should see the following messages nin ansagnment is adapted from one used in the MrTx 60.1s course. Loading word list from file 55969 words loaded. If you see an error instead sxh "No such file or directory.), you may need to change the value of the WORDLIST FILENAME constant (defined near the top of the file) to the complete pathname for the tile words.txt (This will vary based on where you saved the file). The file a2 hangman.py aeady comains three functions functions you will use in your solution You can ignore the details of the code between the fol lowing commeets, though you should read the doctrings so that you undersand how to use each function. # Helper code # You don't need to understand this helper code #but you will have to know how to use the functions # (so be sure to read the docstrings!) (end of helper code) You must do all of your coding for this proklem entirely within this file, because you will be writing a program that depends on cach function you write Requirements Here are the requirements for the game: 1. The compater will select a word a random from a list of available words that was peovided in words.Ext. The functions for loading the word list and selecting a random wond have already been provided for you in a2 hangman-py 2. The game must be interactive; the flow of the game should go as follows: At the start of the game, let the player know how many leters the computer's word contains . Ask the player to supply one gurss (ie. leter) per turn . The player should receive feedback immediately after each guess about whether their guess appears in the computer's word . After each turn, you should also print the partially puessed word as well as the list of letters that the player has not yet guessed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

e. What difficulties did they encounter?

Answered: 1 week ago