Matuiss2

dice game

Sep 11th, 2017
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. import random
  2. start =input("Press enter to begin")
  3. player = random.randint(1, 6)
  4. comp = random.randint(1, 6)
  5. print("Round 1:")
  6. print("Player:", player)
  7. print("Computer:", comp)
  8.  
  9. start2 = input("Press enter to play again")
  10. player2 = random.randint(1, 6)
  11. comp2 = random.randint(1, 6)
  12. print("Round 2")
  13. print("Player:", player2)
  14. print("Computer:", comp2)
  15. total_player1 = player + player2
  16. total_comp1 = comp + comp2
  17. print("Player total:", total_player1)
  18. print("Computer total:", total_comp1)
  19.  
  20. if total_comp1 >= 10 or total_player1 >= 10:
  21.     if total_player1 > total_comp1:
  22.         print("You won")
  23.     elif total_comp1 > total_player1:
  24.         print("The computer won")
  25.     elif total_comp1 == total_player1:
  26.         print("The game is a draw")
  27. else:
  28.     start3 = input("Press enter to play again")
  29.     player3 = random.randint(1, 6)
  30.     comp3 = random.randint(1, 6)
  31.     print("Round 3")
  32.     print("Player:", player3)
  33.     print("Computer:", comp3)
  34.     total_player2 = player + player2 + player3
  35.     total_comp2 = comp + comp2 + comp3
  36.     print("Player total:", total_player2)
  37.     print("Computer total:", total_comp2)
  38.     if total_comp2 >= 10 or total_player2 >= 10:
  39.         if total_player2 > total_comp2:
  40.             print("You won")
  41.         elif total_comp2 > total_player2:
  42.             print("The computer won")
  43.         elif total_comp2 == total_player2:
  44.             print("The game is a draw")
  45.     else:
  46.         print("None of the players reach 10, please play again")
Advertisement
Add Comment
Please, Sign In to add comment