Question: Poker problem Download Program 2 . py and rename it according to the instructions above. Once you fully understand it , modify it to evaluate
Poker problem
Download Programpy and rename it according to the instructions above. Once you fully understand it modify it to evaluate poker hands correctly. When it is run using the hands provided, it should produce poker output.out.
The evaluate function is correct do not modify it
If it is helpful to do so you are welcome to introduce other functions into your solution.
Poker output:
'spades' 'spades' 'spades' 'spades' 'spades' Royal Flush
'clubs' 'clubs' 'clubs' 'clubs' 'clubs' Straight Flush
'clubs' 'diamonds' 'hearts' 'spades' 'clubs' Four of a Kind
'clubs' 'spades' 'clubs' 'diamonds' 'hearts' Full House
'diamonds' 'diamonds' 'diamonds' 'diamonds' 'diamonds' Flush
'clubs' 'clubs' 'spades' 'clubs' 'clubs' Straight
'clubs' 'hearts' 'spades' 'clubs' 'diamonds' Three of a Kind
'diamonds' 'hearts' 'clubs' 'diamonds' 'spades' Two Pair
'diamonds' 'diamonds' 'spades' 'clubs' 'hearts' One Pair
'spades' 'clubs' 'diamonds' 'hearts' 'diamonds' Nothing
program code:
def royalflushhand:
return False
def straightflushhand:
return False
def fourofakindhand:
return False
def fullhousehand:
return False
def flushhand:
return False
def straighthand:
return False
def threeofakindhand:
return False
def twopairhand:
return False
def onepairhand:
return False
#
# Evaluate
#
# pokerhand: a card poker hand, represented
# as a list of lists, eg 'clubs'
#
# Return a string, the poker hand evaluation.
# Do not change this function.
#
def evaluatepokerhand:
Return the string evaluation of a card poker hand
pokerhand.sort # Sort the cards into ascending order
if royalflushpokerhand:
return "Royal Flush"
elif straightflushpokerhand:
return "Straight Flush"
elif fourofakindpokerhand:
return "Four of a Kind"
elif fullhousepokerhand:
return "Full House"
elif flushpokerhand:
return "Flush"
elif straightpokerhand:
return "Straight"
elif threeofakindpokerhand:
return "Three of a Kind"
elif twopairpokerhand:
return "Two Pair"
elif onepairpokerhand:
return "One Pair"
else:
return "Nothing"
#
def main:
Controls the logic of the poker hand evaluation
printCSCI : Poker Hand Evaluation Program"
print
hand "spades" "spades" "spades" "spades" "spades" # royal flush
hand "clubs" "clubs" "clubs" "clubs" "clubs" # straight flush
hand "diamonds" "clubs" "hearts" "clubs" "spades" # of a kind
hand "diamonds" "clubs" "hearts" "clubs" "spades" # full house
hand "diamonds" "diamonds" "diamonds" "diamonds" "diamonds" # flush
hand "clubs" "clubs" "clubs" "clubs" "spades" # straight
hand "diamonds" "clubs" "hearts" "clubs" "spades" # of a kind
hand "spades" "clubs" "diamonds" "diamonds" "hearts" # pair
hand "spades" "clubs" "diamonds" "diamonds" "hearts" # pair
hand "spades" "clubs" "diamonds" "diamonds" "hearts" # nothing
hands hand hand hand hand hand hand hand hand hand hand
for hand in hands:
printhand evaluatehand
#
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
