Question

In this assignment you will implement hangman in python. If you are not famililar with this game, see the wikipedia article linked above This implementation of hangman will be an interactive command-line interface game. Name the script hangman.py. There will be two players (player 1 and player 2). Player 1 will be responsible for choosing the word for player 2 to guess at the beginning of the game. This is the only time that player 1 will input information to the program. For the remainder of the program run, player 2 will be responsible for inputting letter guesses to the program. If player 2 guesses a correct letter, the program will update and will report the players current guessing progress. If the player guesses and incorrect letter, a body part will be added to the hangman, and then the program will ask for another letter. When you first start up hangman, you will see: HANGMAN: Welcome to HANGMAN! HANGMAN: player 1 Enter a hangman word:

Below are expected output examples:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

script.py

#

# Start here

#

print('HANGMAN: Welcome to hangman!')

p_word = input('HANGMAN: Player 1 enter a HANGMAN word : ')

p_word = list(p_word)

word_progress = ['_' for i in range(len(p_word))]

wrong_guess = 6

solved = 0

print('HANGMAN: Wrong guesses left : ',wrong_guess)

print('HANGMAN: Word progress : ',''.join(word_progress))

while wrong_guess > 0:

guess = input('HANGMAN: Player 2 guess a letter : ')

if guess in p_word:

word_progress[p_word.index(guess)] = guess

print('Yes!')

else:

wrong_guess -= 1

print('NOPE!')

if word_progress == p_word:

print('Player 2 wins! ')

exit()

print('HANGMAN: Wrong guesses left : ',wrong_guess)

print('HANGMAN: Word progress : ',''.join(word_progress))

print('Player 1 wins !')

CODE:

OUTPUT:

when player 1 wins

when player 2 wins

C: \Users\Randembet\Desktoplcg python bot.py HANGMAN: Welcome to hangman! HANGMAN: Player 1 enter a HANGMAN word ant HANGMAN:

PLEASE RATE !!!

Add a comment
Know the answer?
Add Answer to:
Below are expected output examples: In this assignment you will implement hangman in python. If you...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Hangman (game) In this project, you are required to implement a program that can play...

    C++ Hangman (game) In this project, you are required to implement a program that can play the hangman game with the user. The hangman game is described in https://en.wikipedia.org/wiki/Hangman_(game) . Your program should support the following functionality: - Randomly select a word from a dictionary -- this dictionary should be stored in an ASCII text file (the format is up to you). The program then provides the information about the number of letters in this word for the user to...

  • For a C program hangman game: Create the function int play_game [play_game ( Game *g )]...

    For a C program hangman game: Create the function int play_game [play_game ( Game *g )] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) (Also the link to program files (hangman.h and library file) is below the existing code section. You can use that to check if the code works) What int play_game needs to do mostly involves calling other functions you've already...

  • This is for C programming: You will be given files in the following format: n word1...

    This is for C programming: You will be given files in the following format: n word1 word2 word3 word4 The first line of the file will be a single integer value n. The integer n will denote the number of words contained within the file. Use this number to initialize an array. Each word will then appear on the next n lines. You can assume that no word is longer than 30 characters. The game will use these words as...

  • Hangman is a game for two or more players. One player thinks of a word, phrase...

    Hangman is a game for two or more players. One player thinks of a word, phrase or sentence and the other tries to guess it by suggesting letters or numbers, within a certain number of guesses. You have to implement this game for Single Player, Where Computer (Your Program) will display a word with all characters hidden, which the player needed to be guessed. You have to maintain a dictionary of Words. One word will be selected by your program....

  • Overview In this exercise you are going to recreate the classic game of hangman. Your program...

    Overview In this exercise you are going to recreate the classic game of hangman. Your program will randomly pick from a pool of words for the user who will guess letters in order to figure out the word. The user will have a limited number of wrong guesses to complete the puzzle or lose the round. Though if the user answers before running out of wrong answers, they win. Requirements Rules The program will use 10 to 15 words as...

  • Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program...

    Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program 3 - Hangman Game Assignment purpose: User defined functions, character arrays, c style string member functions Write an interactive program that will allow a user to play the game of Hangman. You will need to: e You will use four character arrays: o one for the word to be guessed (solution) o one for the word in progress (starword) o one for all of...

  • javafx assisantance confused on where to start Problem Description: (Game: hangman) Write a JavaFX program that...

    javafx assisantance confused on where to start Problem Description: (Game: hangman) Write a JavaFX program that lets a user play the hangman game. The user guesses a word by entering one letter at a time, as shown in Figure followings. If the user misses seven times, a hanging man swings, as shown in Figures. Once a word is finished, the user can press the Enter key to continue to guess another word. Guess a word: ***** God Missed letters Guess...

  • I have to use java programs using netbeans. this course is introduction to java programming so...

    I have to use java programs using netbeans. this course is introduction to java programming so i have to write it in a simple way using till chapter 6 (arrays) you can use (loops , methods , arrays) You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...

  • Currently, the game allows players to play as many times as they wish. It does not...

    Currently, the game allows players to play as many times as they wish. It does not provide any feedback on how the players are doing, however. Modify the game so that it keeps track of the number of games played as well as the average number of guesses made per game. To implement this change, add the following list of global variables to the beginning of the script’s Main Script Logic section. Assign each variable an initial value of zero....

  • Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number...

    Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number guessing game: 1. Function has one input for the number to Guess and one output of the number of attempts needed to guess the value (assume input number will always be between 1 and 1000). 2. If no number was given when the function was called, use random.randint(a,b) to generate a random number between a=1 and b=1000. You will also need to add an...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT