these functions need to be filled with codes. the first image shows the output needed. word.txt contains more than 5000 words which cannot be uploaded here. so provide the program for the output in the image # Hangman Game # ----------------------------------- # 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!) import random import string WORDLIST_FILENAME = "words.txt" # Responses to in-game events # Use the format function to fill in the spaces responses = [ "I am thinking of a word that is {0} letters long", "Congratulations, you won!", "Your total score for this game is: {0}", "Sorry, you ran out of guesses. The word was: {0}", "You have {0} guesses left.", "Available letters: {0}", "Good guess: {0}", "Oops! That letter is not in my word: {0}", "Oops! You've already guessed that letter: {0}", ] def choose_random_word(all_words): """ Chooses a random word from those available in the wordlist Args: all_words (list): list of available words (strings) Returns: a word from the wordlist at random """ return random.choice(all_words) # end of helper code # ----------------------------------- def load_words(): """ Generate a list of valid words. Words are strings of lowercase letters. Returns: A list of valid words. """ # TODO: Fill in your code here # Load the list of words into the variable wordlist # Accessible from anywhere in the program # TODO: uncomment the below line once # you have implemented the load_words() function # wordlist = load_words() def is_word_guessed(word, letters_guessed): """ Determine whether the word has been guessed Args: word (str): the word the user is guessing letters_guessed (list): the letters guessed so far Returns: boolean, True if all the letters of word are in letters_guessed; False otherwise """ # TODO: Fill in your the code here def get_guessed_word(word, letters_guessed): """ Determines the current guessed word, with underscores Args: word (str): the word the user is guessing letters_guessed (list): which letters have been guessed so far Returns: string, comprised of letters, underscores (_), and spaces that represents which letters have been guessed so far. """ # TODO: Fill in your code here def get_remaining_letters(letters_guessed): """ Determine the letters that have not been guessed Args: letters_guessed: list (of strings), which letters have been guessed Returns: String, comprised of letters that haven't been guessed yet. """ # TODO: Fill in your code here def hangman(word): """ Runs an interactive game of Hangman. Args: word: string, the word to guess. """ print("Welcome to Hangman Ultimate Edition") print("I am thinking of a word that is {0} letters long".format(len(word))) print("-------------") # TODO: Fill in your code here # When you've completed your hangman function, scroll down to the bottom # of the file and uncomment the last lines to test # (hint: you might want to pick your own # word while you're doing your own testing) # ----------------------------------- # Driver function for the program if __name__ == "__main__": # Uncomment the line below once you have finished testing. # word = choose_random_word(wordlist) # Uncomment the line below once you have implemented the hangman function. # hangman(word)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

these functions need to be filled with codes. the first image shows the output needed. word.txt contains more than 5000 words which cannot be uploaded here. so provide the program for the output in the image
# Hangman Game

# -----------------------------------
# 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!)
import random
import string

WORDLIST_FILENAME = "words.txt"

# Responses to in-game events
# Use the format function to fill in the spaces
responses = [
    "I am thinking of a word that is {0} letters long",
    "Congratulations, you won!",
    "Your total score for this game is: {0}",
    "Sorry, you ran out of guesses. The word was: {0}",
    "You have {0} guesses left.",
    "Available letters: {0}",
    "Good guess: {0}",
    "Oops! That letter is not in my word: {0}",
    "Oops! You've already guessed that letter: {0}",
]

def choose_random_word(all_words):
    """
    Chooses a random word from those available in the wordlist
    
    Args:
        all_words (list): list of available words (strings)
    
    Returns:
        a word from the wordlist at random
    """
    return random.choice(all_words)


# end of helper code
# -----------------------------------

def load_words():
    """
    Generate a list of valid words. Words are strings of lowercase letters.

    Returns:
        A list of valid words.
    """
    # TODO: Fill in your code here


# Load the list of words into the variable wordlist
# Accessible from anywhere in the program
# TODO: uncomment the below line once
# you have implemented the load_words() function

# wordlist = load_words()

def is_word_guessed(word, letters_guessed):
    """
    Determine whether the word has been guessed

    Args:
        word (str): the word the user is guessing
        letters_guessed (list): the letters guessed so far
    
    Returns: 
        boolean, True if all the letters of word are in letters_guessed; False otherwise
    """
    # TODO: Fill in your the code here

def get_guessed_word(word, letters_guessed):
    """
    Determines the current guessed word, with underscores

    Args:
        word (str): the word the user is guessing
        letters_guessed (list): which letters have been guessed so far
    
    Returns: 
        string, comprised of letters, underscores (_), and spaces that represents which letters have been guessed so far.
    """
    # TODO: Fill in your code here

def get_remaining_letters(letters_guessed):
    """
    Determine the letters that have not been guessed
    
    Args:
        letters_guessed: list (of strings), which letters have been guessed
    
    Returns: 
        String, comprised of letters that haven't been guessed yet.
    """
    # TODO: Fill in your code here

def hangman(word):
    """
    Runs an interactive game of Hangman.

    Args:
        word: string, the word to guess.
    """
    print("Welcome to Hangman Ultimate Edition")
    print("I am thinking of a word that is {0} letters long".format(len(word)))
    print("-------------")
    # TODO: Fill in your code here

# When you've completed your hangman function, scroll down to the bottom
# of the file and uncomment the last lines to test
# (hint: you might want to pick your own
# word while you're doing your own testing)


# -----------------------------------

# Driver function for the program
if __name__ == "__main__":
    # Uncomment the line below once you have finished testing.
    # word = choose_random_word(wordlist)

    # Uncomment the line below once you have implemented the hangman function.
    # hangman(word)

 

Example Implementation (input in red):
Loading word list from file...
55900 words loaded.
Welcome to Hangman Ultimate Edition
Do you want to Play (p) view the leaderboard (1) or quit (q): p
Score
Name
7
Matthew Howell
Herbert Daly
3
Hiran Patel
Would you like to play (p) or view the leaderboard (1): p
What is your name: Matthew Howell
I am thinking of a word that is 2 letters long
You have 6 guesses left.
Available letters: abcdefghijklmnopqrstuvwxyz
Please guess a letter: a
Good guess: a
---
You have 6 guesses left.
Available letters: bcdefghijklmnopqrstuvwxyz
Please guess a letter: n
Good guess: an
Congratulations, you won!
Your total score for this game is: 9
A new personal best! Would you like to save your score (y/n): y
Ok, your score has been saved.
Do you want to Play (p) view the leaderboard (l) or quit (q) : q
Thanks for playing, goodbye!
Transcribed Image Text:Example Implementation (input in red): Loading word list from file... 55900 words loaded. Welcome to Hangman Ultimate Edition Do you want to Play (p) view the leaderboard (1) or quit (q): p Score Name 7 Matthew Howell Herbert Daly 3 Hiran Patel Would you like to play (p) or view the leaderboard (1): p What is your name: Matthew Howell I am thinking of a word that is 2 letters long You have 6 guesses left. Available letters: abcdefghijklmnopqrstuvwxyz Please guess a letter: a Good guess: a --- You have 6 guesses left. Available letters: bcdefghijklmnopqrstuvwxyz Please guess a letter: n Good guess: an Congratulations, you won! Your total score for this game is: 9 A new personal best! Would you like to save your score (y/n): y Ok, your score has been saved. Do you want to Play (p) view the leaderboard (l) or quit (q) : q Thanks for playing, goodbye!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY