Question: Declare a function in python named input _ guess. The function will prompt for and eventually return the user's row or column guess. More specifically,

Declare a function in python named input_guess. The function will prompt for and eventually return the user's row or column guess. More specifically, the function takes in an int parameter representing the size of the grid, a str parameter representing a specification of row or column, and an int return type. Since the caller of this function can be expected to provide a correct argument for the str parameter, specifically one that is "row" or "column, we will "assert" this assumption in our code such that an error is raised if it is not found to be true. As the first line of code in your function's body, add the following assert statement and fill in the blank I with your second parameter's name:
assert ___= "row" or ___= "column"
Declare a function named print_grid. Given the size of the grid, the user's row and column guesses, and whether the guesses were correct the function will print a grid of boxes to represent the game board. The function has:
An int parameter representing the size of the grid.
An int parameter representing the row guess.
An int parameter representing the column guess.
A bool parameter representing if the user's guess was correct.
A None return type.
Declare a function named correct_guess. Given the secret boat locatior and the user's guess, the function will return if the user was correct or not. The function should take in four int parameters representing the secret row, the secret column, the row guess, and the column guess, and it will return a bool.
Now, it's finally time to implement the main function that will pull together each of the smaller pieces that you created in your program. Similar to your other functions, the main functions has certain specifications including:
An int parameter for grid size.
An int parameter for secret row.
An int parameter for secret column.
A return type of None.
The "state" of a game refers to the variables you need to keep track of in memory in order to run the game. What variables do you need to keep track of? Define those inside of main's body first.
Then, begin the game loop while the user still has turns left to play and the user hasn't won yet, you will want to do the following:
Print the current turn number in a format such as === Turn 15=== Prompt the user for a row and column guess, relying on your function input_guess to obtain a guess within the proper bounds.
Verify the user's guess using correct_guess.
Codify the emoji results of the user's guess by making use of your print_grid function.
If the user's guess is correct, the user has won! Print Hit! and You won in N5 turns! where N is replaced with the number of guesses it took. End the loop by updating the appropriate variables.
Otherwise, print Miss! and move on to the next turn.
If the user has exhausted all turns, print X/5- Better luck next Time! Where X is literally the character X and end the game.
 Declare a function in python named input_guess. The function will prompt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!