Open with Google Docs ENG-101 Intro Computing Engineers Homework 4 DUE START OF
ID: 3907422 • Letter: O
Question
Open with Google Docs ENG-101 Intro Computing Engineers Homework 4 DUE START OF CLASS: MW 27 JUNE 2018, T/R 26 JUNE 2018 SUBMITTED TO CANVAS Question 1: (25 points) Write well-documented Python program to play Rock, Paper, Scissors...: Sheldon Cooper, the fictional character on the CBS TV show "The Big Bang Theory", has extended the game Rock Papers Scissors as described below. Write a well-documented Python program entitled, rockPaper.py, to implement the game accepting a user input. The main program should allow for lower /upper case user entries. Additionally, the main program should display the number of times the user won the game during a playing session. Its Simple spock smashes sossors scissors cuts paper decapitates paper covers iuand poisons spock a + Page 12Explanation / Answer
import random
num_uwin = 0
num_cwin = 0
num_game = 0
while True:
winner = ""
while winner == "":
compChoice = random.choice(["rock","paper","scissors","lizard","spock"])
user = input("Enter your choice(rock/paper/scissors/lizard/spock:")
user = user.lower()
print("Computer's choice:",compChoice)
if user == "rock":
if compChoice == "scissor":
winner = "You"
num_uwin = num_uwin + 1
if compChoice == "paper":
winner = "Computer"
num_cwin = num_cwin + 1
if compChoice == "lizard":
winner = "You"
num_uwin = num_uwin + 1
if compChoice == "spock":
winner = "Computer"
num_cwin = num_cwin + 1
if user == "paper":
if compChoice == "rock":
winner = "You"
num_uwin = num_uwin + 1
if compChoice == "scissors":
winner = "Computer"
num_cwin = num_cwin + 1
if compChoice == "lizard":
winner = "Computer"
num_cwin = num_cwin + 1
if compChoice == "spock":
winner = "You"
num_uwin = num_cwin + 1
if user == "scissors":
if compChoice == "paper":
winner = "You"
num_uwin = num_uwin + 1
if compChoice == "rock":
winner = "Coumputer"
num_cwin = num_cwin + 1
if compChoice == "lizard":
winner = "Coumputer"
num_cwin = num_cwin + 1
if compChoice == "spock":
winner = "Coumputer"
num_cwin = num_cwin + 1
if user == "spock":
if compChoice == "paper":
winner = "Computer"
num_cwin = num_cwin + 1
if compChoice == "rock":
winner = "You"
num_uwin = num_uwin + 1
if compChoice == "lizard":
winner = "Coumputer"
num_cwin = num_cwin + 1
if compChoice == "scissors":
winner = "You"
num_uwin = num_uwin + 1
if user == "lizard":
if compChoice == "paper":
winner = "You"
num_uwin = num_uwin + 1
if compChoice == "rock":
winner = "Computer"
num_cwin = num_cwin + 1
if compChoice == "spock":
winner = "You"
num_uwin = num_uwin + 1
if compChoice == "scissors":
winner = "Computer"
num_cwin = num_cwin + 1
num_game = num_game + 1
print(winner, "won")
ch = input("Do you want to play again(Y/N)?")
if ch == "N":
break
print("The number of times user won:", num_uwin)
print("The number of times computer won:", num_cwin)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.