Advertisement
dollarortwo

war1

Nov 13th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. # http://www.rdb3.com/python/exercises/6.8.pdf
  2. import random
  3.  
  4. computerCardValue = random.randint(2, 14)
  5. computerSuitValue = random.randint(0, 3)
  6.  
  7. humanCardValue = random.randint(2, 14)
  8. humanSuitValue = random.randint(0, 3)
  9.  
  10. print("Computer's card is a ", end=" ")
  11.  
  12. if computerCardValue == 11:
  13. print("Jack", end="")
  14. elif computerCardValue == 12:
  15. print("Queen", end="")
  16. elif computerCardValue == 13:
  17. print("King", end="")
  18. elif computerCardValue == 14:
  19. print("Ace", end="")
  20. else:
  21. print(computerCardValue, end="")
  22.  
  23.  
  24. print(" of ", end="")
  25.  
  26.  
  27. if computerSuitValue == 0:
  28. print("Spades")
  29. elif computerSuitValue == 1:
  30. print("Hearts")
  31. elif computerSuitValue == 2:
  32. print("Diamonds")
  33. else:
  34. print("Clubs")
  35.  
  36. print("Human's card is a ", end="")
  37.  
  38. if humanCardValue == 11:
  39. print("Jack", end="")
  40. elif humanCardValue == 12:
  41. print("Queen", end="")
  42. elif humanCardValue == 13:
  43. print("King", end="")
  44. elif humanCardValue == 14:
  45. print("Ace", end="")
  46. else:
  47. print(humanCardValue, end="")
  48.  
  49. print(" of ", end="")
  50.  
  51.  
  52. if humanSuitValue == 0:
  53. print("Spades")
  54. elif humanSuitValue == 1:
  55. print("Hearts")
  56. elif humanSuitValue == 2:
  57. print("Diamonds")
  58. else:
  59. print("Clubs")
  60.  
  61. if computerCardValue < humanCardValue:
  62. print("Human wins")
  63. elif computerCardValue > humanCardValue:
  64. print("Computer Wins")
  65. else:
  66. print("It's tie")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement