Text Size
Text Size
Exit Full Screen
Python Mini
Show
Source Code
View Source Code in Full Screen
Open in New Tab
import random, time choices = ["rock", "paper", "sissors"] pScore = 0 cScore=0 for i in range(3): pchoice = raw_input("Enter a choice: rock, paper, sissors") pchice = pchoice.lower() print "Player's choice:", pchoice if pchoice not in choices: print "That is not a valid opition. Game Over" break cchoice = random.choice(choices) print "Computer's Choice:", cchoice if((pchoice== "rock" and cchoice == "sissors") or ( pchoice== "sissors" and cchoice== "paper")or ( pchoice== "paper" and cchoice == "rock")): print "Player wins this round" pScore += 1 elif((pchoice== "sissors" and cchoice == "rock") or ( pchoice== "paper" and cchoice== "sissors")or ( pchoice== "rock" and cchoice == "paper")): print "Computer wins this round" cScore += 1 elif pchoice == cchoice: print "Tie" print time.sleep(1) if pScore > cScore: print "Player wins!!!" elif cScore > pScore: print "Computer wins!!!" else: print "It's a tie!!"
rockpapperscissors.py
( around 33 lines python code )
Published By:
mu7165
Published on
2017-08-02T18:22:18Z
Python Mini
- an
OYOclass
application,
own your own class today
.
Run
Result
×
Error message shows here