Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # http://www.rdb3.com/python/exercises/6.8.pdf
- import random
- computerCardValue = random.randint(2, 14)
- computerSuitValue = random.randint(0, 3)
- humanCardValue = random.randint(2, 14)
- humanSuitValue = random.randint(0, 3)
- print("Computer's card is a ", end=" ")
- if computerCardValue == 11:
- print("Jack", end="")
- elif computerCardValue == 12:
- print("Queen", end="")
- elif computerCardValue == 13:
- print("King", end="")
- elif computerCardValue == 14:
- print("Ace", end="")
- else:
- print(computerCardValue, end="")
- print(" of ", end="")
- if computerSuitValue == 0:
- print("Spades")
- elif computerSuitValue == 1:
- print("Hearts")
- elif computerSuitValue == 2:
- print("Diamonds")
- else:
- print("Clubs")
- print("Human's card is a ", end="")
- if humanCardValue == 11:
- print("Jack", end="")
- elif humanCardValue == 12:
- print("Queen", end="")
- elif humanCardValue == 13:
- print("King", end="")
- elif humanCardValue == 14:
- print("Ace", end="")
- else:
- print(humanCardValue, end="")
- print(" of ", end="")
- if humanSuitValue == 0:
- print("Spades")
- elif humanSuitValue == 1:
- print("Hearts")
- elif humanSuitValue == 2:
- print("Diamonds")
- else:
- print("Clubs")
- if computerCardValue < humanCardValue:
- print("Human wins")
- elif computerCardValue > humanCardValue:
- print("Computer Wins")
- else:
- print("It's tie")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement