#Rock, Paper, Scissors, Game import time import random #intro print("Welcome to Rock, Paper, Scissors") print("Ready to play? Y or N") ready = input() if ready =="Y": print("Let's get started") print("LOADING....") time.sleep(3) else: exit() #main keepPlaying = True #keeps track of the player's score pScore=0 #keeps track of the computer's score cScore=0 #runs as long as player inputs number 1-3 while keepPlaying: #chooses randomly what computer draws cNum = random.randrange(1,3) print("What do you choose?\nRock(1) \nPaper(2)\nScissors(3)\nENTER ANY OTHER NUMBER TO QUIT") pNum= input() #changes the type from String to Input pNum= int(pNum) #handles the different answers if pNum==cNum: print("It's a draw") #user chooses rock AND computer chooses paper elif pNum== 1 and cNum==2: print("The Computer drew paper. You lost.") cScore++1 #user chooses rock AND computer chooses scissors elif pNum==1 and cNum==3: print("The Computer drew scissors.You win.") pScore+=1 #user chooses paper AND computer chooses scissors elif pNum==2 and cNum==3: print("The Computer drew scissors. You lose") cScore+=1 #user chooses paper AND computer chooses rock elif pNum==2 and cNum==1: print("The Computer drew rock. You win.") pScore+=1 #user chooses scissors AND computer chooses rock elif pNum==3 and cNum==1: print("The Computer drew rock. You lose.") cScore+=1 #user chooses scissors AND computer chooses paper elif pNum==3 and cNum==2: print("The Computer drew paper. You win.") pScore+=1 else: keepPlaying= False print("Your Score: %s" %pScore) print("Computer Score: %s" %cScore) time.sleep(2) print("***Final Score***") print("Your Score: %s" %pScore) print("Computer Score: %s" %cScore) if pScore>cScore: print("YOU WIN!!!!!!!!!") elif cScore>pScore: print("YOU LOSE :((((((((") elif cScore==pScore: print("IT'S A TIE") time.sleep(5) exit()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question