Question: URGENT!!! Question 1 (8 points): Purpose: To practice using loops to repeat actions until a condition is met (and solve a practical problem at the
Question 1 (8 points): Purpose: To practice using loops to repeat actions until a condition is met (and solve a practical problem at the same time!). Degree of Difficulty: Moderate "Which hand" is a simple game of chance played by 2 people. The game is played in rounds, and the player who wins 3 rounds first wins the game. In each round, one player hides a coin in their palm and asks the other player to guess the correct hand (left or right hand). Then the other player makes a guess and if they get it right, they win a round. If they get it wrong, the other player wins the round. When the game is won, the players switches roles and starts another match. In this version of the game, player 1 always hides the coin and player 2 guesses it. For this question, write a program which does the following: - Prompt the first player to enter the hand where they want to hide the coin. The player must input "l" for left, or " r " for right in the console. - Prompt the second player to guess the hand where the coin is hidden. Just like the previous player, player 2 must input "l" for left, or " r " for right in the console. - If any player enters a value other than "I" or " r, the program will ask that player ro re-enter their response until the player enters I" or "r". - Print the player who wins the round. - Print the player who wins 3 rounds first. Hint: You will need nested loops for this code. Sample Run Sample input and output (input typed by the user is shown in green text): Round I: Player , Hide coin in left or right hand? (1/r) : 1 Player2, Guess! Left or t ight hand? (1/I):= Player2, You guessed it wrong! Round 2: Player1, Hide coin in left or right hand? (1/r)=t Player2, Guess! Left or right hand? (1/I):= Player2, Please make a valid guess! Left or right hand? (I/I): : Player2, You quessed it correctiy! Round 3: Player1, Hide coin in left or right hand? (1/r)=1 Player2, Guess! Left or t ight hand? (1/r)=1 Player2, You guessed it correctly! Round 4: Player1, Hide coin in left or r ight hand? (2/r):= Player2, Guess! Left or x ight hand? (1/I):= Player2, You guessed it correctly! Playet 2 wins
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
