Advertisement
calcpage

CM_rps.py

Jan 6th, 2012
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. #!/usr/bin/python
  2. from random import choice
  3. peep = input('enter r, p or s to play!')
  4. comp = choice('rps')
  5. peepScore = 0
  6. compScore = 0
  7. numTies = 0
  8. while peep != 'q':
  9.     if peep == 'r':
  10.         if comp == 'r':
  11.             print "rock vs rock is a tie!"
  12.             numTies += 1
  13.         if comp == 'p':
  14.             print "rock vs paper, comp wins!!"
  15.             compScore += 1
  16.         if comp == 's':
  17.             print "rock vs scissors, peep wins!!!"
  18.             peepScore += 1
  19.     if peep == 'p':
  20.         if comp == 'r':
  21.             print "paper vs rock, peep wins!!!"
  22.             peepScore += 1
  23.         if comp == 'p':
  24.             print "paper vs paper is a tie!"
  25.             numTies += 1
  26.         if comp == 's':
  27.             print "paper vs scissors, comp wins!!"
  28.             compScore += 1
  29.     if peep == 's':
  30.         if comp == 'r':
  31.             print "scissors vs rock, comp wins!!"
  32.             compScore += 1
  33.         if comp == 'p':
  34.             print "scissors vs paper, peep wins!!!"
  35.             peepScore += 1
  36.         if comp == 's':
  37.             print "scissors vs scissors is a tie!"
  38.             numTies += 1
  39.     peep = input('enter r, p or s to play or q to quit')
  40.     comp = choice('rps')
  41. print "peep score = " + str(peepScore)
  42. print "comp score = " + str(compScore)
  43. print "number of ties = " + str(numTies)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement