Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. def numberToName(number):
  5. if number == 1:
  6. choice = 'rock'
  7. elif number == 2:
  8. choice = 'paper'
  9. else:
  10. choice = 'scissors'
  11. return choice
  12.  
  13.  
  14. def rockPaperScissors():
  15. player1 = numberToName(int(input()))
  16. player2 = numberToName(random.randint(1, 3))
  17. if player1 == 'rock' and player2 == 'rock':
  18. print("Player1 choose rock")
  19. print("Player2 choose rock")
  20. print('Player1 and Player2 tied')
  21. elif player1 == 'paper' and player2 == 'paper':
  22. print("Player1 choose paper")
  23. print("Player2 choose paper")
  24. print('Player1 and Player2 tied')
  25. elif player1 == 'scissors' and player2 == 'scissors':
  26. print("Player1 choose scissors")
  27. print("Player2 choose scissors")
  28. print('Player1 and Player2 tied')
  29. elif player1 == 'rock' and player2 == 'paper':
  30. print("Player1 choose rock")
  31. print("Player2 choose paper")
  32. print("Player2 wins")
  33. return "Player2 wins"
  34.  
  35.  
  36. elif player1 == 'rock' and player2 == 'scissors':
  37. print("Player1 choose rock")
  38. print("Player2 choose scissors")
  39. print('Player1 wins')
  40. return 'Player1 wins'
  41. elif player1 == 'scissors' and player2 == 'paper':
  42. print("Player1 choose scissors")
  43. print("Player2 choose paper")
  44. print('Player1 wins')
  45. return 'Player1 wins'
  46. elif player1 == 'scissors' and player2 == 'rock':
  47. print("Player1 choose scissors")
  48. print("Player2 choose rock")
  49. print("Player2 wins")
  50. return "Player2 wins"
  51.  
  52. elif player1 == 'paper' and player2 == 'rock':
  53. print("Player1 choose paper")
  54. print("Player2 choose rock")
  55. print('Player1 wins')
  56. return "Player1 wins"
  57. elif player1 == 'paper' and player2 == 'scissors':
  58. print("Player1 choose paper")
  59. print("Player2 choose scissors")
  60. print("Player2 wins")
  61. return "Player2 wins"
  62.  
  63.  
  64. def countLetters(word, char):
  65. W = 0
  66. L = 0
  67.  
  68. while W <= 2:
  69. if rockPaperScissors() != 'Player1 wins':
  70. continue
  71. W = W + word
  72. if W == 2:
  73. print('Player1 wins the whole match with', W, 'out of 3.')
  74. elif rockPaperScissors() != 'Player2 wins':
  75. continue
  76. L = L + word
  77. if L == 2:
  78. print('Player2 wins the whole match with', L, 'out of 3.')
  79.  
  80. break
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96. if __name__ == '__main__':
  97. userInput = 0
  98.  
  99. while userInput != -1:
  100. print("\nPlease select one of the menu options")
  101. print(" 1. Start game of rock, paper, scissors")
  102. print("-1. to exit the program.")
  103. userInput = input()
  104. if (userInput == '1'):
  105. print('\nStarting Game... Input 1 for rock, 2 for paper or 3 for scissor.\n')
  106. elif userInput == '-1':
  107. break
  108.  
  109. while True:
  110. value = countLetters(1, char='')
  111.  
  112. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement