Question: Need help with this Lab . Rock, Paper, Scissors! Write a program which let's the user play rock, paper, scissors against the computer. It should:

Need help with this Lab .
Rock, Paper, Scissors! Write a program which let's the user play rock, paper, scissors against the computer. It should:
Ask for the users name, utilize in output for scoring and messages
Randomly generate the computer's choice ("rock", "paper" or "scissors")
Ask the user to enter their choice ("rock", "paper" or "scissors")
Display the computer's choice
Compare the choices, then determine a winner:
rock beats scissors
paper beats rock
scissors beat paper
a tie results in a do-over until a winner is declared
The winner (user or computer) gets a point
After each round, display the total score for the user and the computer
Ask if the user wants to play again
If yes, then display another round
If no, then display the total number of rounds played and the final score
Helpful hint: use numbers to represent the computer's choices. For example: 1=rock, 2=scissors, 3=paper. This can make it easier to randomly generate the computer's choice.
Here's my code but it missing mainline logic and correct function design, coupled with syntax errors.
from random import *
def main():
# variable
userPoint =0;
computerPoint =0;
roundCount =0;
comp =["rock","paper","scissors"]
# loop
while(True):
roundCount +=1
# internal loop till winner
while(True):
# generate computer choice
compChoice = randint(0,2)
compCh = comp[compChoice]
# ask user choice
uchoice = str(input("Enter your choice "))
'''rock beats scissors
paper beats rock
scissors beat paper'''
if(uchoice == "rock" and compCh == "scissors"):
userPoint +=1
break;
elif(uchoice == "scissors" and compCh == "rock"):
computerPoint +=1
break;
elif(uchoice == "rock" and compCh == "paper"):
computerPoint +=1
break;
elif(uchoice == "paper" and compCh == "rock"):
userPoint +=1
break;
elif(uchoice == "scissors" and compCh == "paper"):
userPoint +=1
break;
elif(uchoice == "paper" and compCh == "scissors"):
computerPoint +=1
break;
else:
print("Choice same Try Again")
x = int(input("Enter 1 to continue else 0"))
if(x ==0):
break;
# print result
print("
Total Rounds ="+str(roundCount))
print("User Score ="+str(userPoint))
print("Computer Score ="+str(computerPoint))
# PROGRAM EXECUTION STARTS HERE
main()
Please answer asap.

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!