Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE SOLVE IN PYTHON. I'm using pycharm, I'm having a lot of trouble. The purpose of this project is to demonstrate your understanding of the

PLEASE SOLVE IN PYTHON. I'm using pycharm, I'm having a lot of trouble. "The purpose of this project is to demonstrate your understanding of the Python programming language fundamentals that you have studied. You will do this through the creation/completion of a game similar to Hangman. (also the def main() function is supposed to come first in the code)"

# Create a method that accepts a string as a message # and asks the user a question with that message (input). Then return the user's response as the return value of the method

Name: getQuestionNumber

Input: string

Returns: string

# Create a method that accepts the word the user guessed, as well as the correct answer and compares the two. If they match, return a string that tells the user that they guessed correctly, and tells them the guess and the correct answer. Make sure the word they submitted as a guess appears to them wrapped in double quotes.

Name: correctMessage

Input: string, string

Returns: string

# Create a method that accepts the word the user guessed, as well as the correct answer and compares the two as lowercase strings. If they match, return True, otherwise return False Name: isCorrect

Input: string, string

Returns: bool

# Create a method that accepts a string as a message and asks the user a question with that message (input). Then return the user's response as the return value of the method

Name: tryAnswer

Input: string

Returns: string

# Create a method that accepts the correct answer return a string that tells the user that the game is over, and what the correct answer was. Make sure the word they submitted as a guess appears to them wrapped in double quotes

Name: gameOver

Input: string

Returns: string

def main():

# Create a dictionary of dictionaries that contain the following pairs: An integer key, and a dictionary value. The dictionary value is a dictionary with the question's answer, as the key, and the clue as the value. Assign the dictionary to a variable called cluesDictionary

cluesDictionary = {1: {"whale": "This is the largest mammal type"}, 2: {"eagle": "This is the US national bird"}, 3: {"football": "This popular sport is played with helmets and pads"}, 4: {"hawaii": "This state is a collection of islands"}, 5: {"moon": "This satellite helps control the tides"}}

getQuestionNumber = input("Enter as question number from 1 to 5, and you will play that clue. Enter -1 to quit ")

# Create a string variable that holds the following message: "Enter as question number from 1 to 5, and you will play that clue. Enter -1 to quit "

# Create a bool variable to tell the game whether to keep looping, or to quit the game. Initialize the variable to True.

# Begin a while loop that the rest of the game will live inside. The while loop should be a terminal loop that will be ended with a break statement later if the user enters a value of "-1"

# Using a try/except block, ask the user for a number and convert the result to an integer. Be sure to use the getQuestionNumber method to ask for the number If the user's answer cannot be converted to an integer make sure the exception block ends with a continue statement so that the user is asked the question again

# If the user entered "-1" as the question number # tell the user "Goodbye", and set the variable called keepGoing to False. Also make sure the block ends with a break statement so the while loop terminates

# If the question number is not a value between # 1 and 5, return to the top of the loop with a continue statement so the question is asked again

# Set a variable that creates a string message showing the clue and ends with "What is it?" questionMessage = list(cluesDictionary[questionNumber].values())[0] + ". What is it?"

# Set a variable that creates a string message showing the answer # in lower case questionAnswer = list(cluesDictionary[questionNumber].keys())[0].lower()

#Tell the user the clue, and ask them for the correct answer. Be sure to use the tryAnswer method for this, and to pass in the right argument (the variable questionMessage)

# If the user entered the correct word, congratulate them and tell them what they entered and what the correct word was. Be sure to use the isCorrect and correctMessage methods to complete this, Else tell the user they entered an incorrect word. Use a for loop to loop through letters in the correct answer until they guess correctly or until they have attempted to answer the same number of times as there are letters in the answer word. You must tell them that they are either on the first letter, the last letter or another letter in the middle when you present the letters.

# Create a counter variable to know the current position you are at in the answer word

# Begin a for loop to loop through the answer word that was answered incorrectly

# If this is the first letter, tell them so, and what the letter is Increment the counter. Tell them to guess again using the tryAnswer method. Use the isCorrect method to determine if the new answer is correct. If the new answer is correct tell them so using the correctMessage method and break from the for loop

# If this is the last letter, tell them so, and what the letter is Increment the counter Tell them what the last letter was and tell them, using the gameOver method, to play again

# If this is a letter other than the first or last letter, tell them so, and what the letter is Increment the counter Tell them to guess again using the # tryAnswer method. Use the isCorrect method to determine if the new answer is correct. If the new answer is correct tell them so using the correctMessage method and break from the for loop end for end while main()

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

MFDBS 89 2nd Symposium On Mathematical Fundamentals Of Database Systems Visegrad Hungary June 26 30 1989 Proceedings

Authors: Janos Demetrovics ,Bernhard Thalheim

1989th Edition

3540512519, 978-3540512516

Students also viewed these Databases questions

Question

What does gradual refinement mean in the context of SDLC?

Answered: 1 week ago

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

Discuss communication challenges in a global environment.

Answered: 1 week ago