Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write code in python 3.0 thank you Which hand' is a simple game of chance played by 2 people. The game is played in rounds,

image text in transcribedWrite code in python 3.0 thank you

"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. 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. The console will ask for inputs until the players enters the correct one ("l" 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 1 : Player1, Hide coin in left or right hand? (1/r): 1 Player 2, Guess! Left or right hand? (1/r): r Player 2, You guessed it wrong! Round 2: Player1, Hide coin in left or right hand? (1/r): r Player 2, Guess! Left or right hand? (1/r): w Player 2, Please make a valid guess! Left or right hand? (1/r): r Player 2, You guessed it correctly! Round 3: Player1, Hide coin in left or right hand? (1/r): 1 Player 2, Guess! Left or right hand? (1/r): 1 Player 2, You guessed it correctly! Round 4: Playeri, Hide coin in left or right hand? (1/r): r Player 2, Guess! Left or right hand? (1/r): r Player 2, You guessed it correctly! Player 2 wins

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

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

d. What language(s) did they speak?

Answered: 1 week ago