Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that allows a user to play 5 rounds of Rock Paper Scissors against a computer opponent. The user will be prompted with
Write a program that allows a user to play 5 rounds of Rock Paper Scissors against a computer opponent. The user will be prompted with a choice between Rock, Paper, and Scissors. A random selection between Rock, Paper, and Scissors.
Step by Step Solution
★★★★★
3.38 Rating (170 Votes )
There are 3 Steps involved in it
Step: 1
Python Programming Code to copy Importing a random module import random Variable to store player wins count userwins 0 Loop to simulate 5 rounds for i in range1 6 Printing current round number printRoundi Taking input for player choice userchoice intinputEnter your choice1Rock 2Paper 3Scissors Loop to validate user input while userchoice not in 123 userchoice intinputInvalid choice 1 2 or 3 Generating computer choice computerchoice randomchoiceRock Paper Scissors Printing computer choice printComputer chose computerchoice Based on user choice finding who won and incrementing player wins if userchoice 1 if computerchoice Rock printThe round is a draw elif computerchoice Paper printPaper beats Rock Computer wins else printRock beats Scissors Player wins userwins 1 elif userchoice 2 if computerchoice Paper printThe round is a draw elif computerchoice Rock printPaper beats Rock Player wins userwins 1 else printScissors beats Paper Computer wins else if computerchoice Scissors printThe round is a draw elif computerchoice Paper printScissors beats Paper Player wins userwins 1 else printRock beats Scissors Computer wins printYou have wonuserwinsofirounds Calculating player win ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started