Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. import random
  2.  
  3. def play():
  4. p = []
  5. c = []
  6. movep = ["rock", "paper", "scissors"]
  7. movec = ["rock", "paper", "scissors"]
  8. pick = input("Pick 0 for rock, 1 for paper, 2 for scissors")
  9. p.append(movep[pick])
  10. c.append(random.choice(movec))
  11. print p
  12. print c
  13. if p == c:
  14. result = "tie"
  15. return result
  16. elif p == "rock" and c == "paper":
  17. result = "c"
  18. return result
  19. elif p == "rock" and c == "scissors":
  20. result = "p"
  21. return result
  22. elif p == "paper" and c == "rock":
  23. result = "p"
  24. return result
  25. elif p == "paper" and c == "scissors":
  26. result = "c"
  27. return result
  28. elif p == "scissors" and c == "rock":
  29. result = "c"
  30. return result
  31. elif p == "scissors" and c == "paper":
  32. result = "p"
  33. return result
  34. for i in p:
  35. del i
  36. for i in c:
  37. del i
  38.  
  39. def scoring():
  40. pscore = 0
  41. cscore = 0
  42. while cscore != 5 or pscore != 5:
  43. result = play()
  44. if result == "p":
  45. pscore = pscore + 1
  46. print player, "=", pscore
  47. print computer, "=", cscore
  48. elif result == "tie":
  49. pscore = pscore + 1
  50. cscore = cscore + 1
  51. print player, "=", pscore
  52. print computer, "=", cscore
  53. elif result == "c":
  54. cscore = cscore + 1
  55. print player, "=", pscore
  56. print computer, "=", cscore
  57. if pscore == 5:
  58. print player, "wins the game!"
  59. print player, "=", pscore
  60. print computer, "=", cscore
  61. elif cscore == 5:
  62. print computer, "wins the game!"
  63. print player, "=", pscore
  64. print computer, "=", cscore
  65.  
  66. #main
  67. player = raw_input("What is your name?")
  68. computer = raw_input("What name do you give your opponent?")
  69. start = raw_input("First one to win 5 times wins, press enter to play!")
  70. scoring()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement