Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Poker hand test To solve this problem, you need to understand the following Python concepts: lists, functions, loops and if statements. Your program will be
Poker hand test
To solve this problem, you need to understand the following Python concepts: lists, functions, loops and if statements.
Your program will be tested on a different set of poker hands than the ones that appear in the main function of poker.py Thus, it is important that you test your program on different inputs and identify the different types of poker hands in a general fashion.
points Every royal flush is identified correctly. All or nothing.
points Every straight flush is identified correctly. All or nothing.
points Every four of a kind is identified correctly. All or nothing.
points Every full house is identified correctly. All or nothing.
points Every flush is identified correctly. All or nothing.
points Every straight is identified correctly. All or nothing.
points Every three of a kind is identified correctly. All or nothing.
points Every two pair is identified correctly. All or nothing.
points Every pair is identified correctly. All or nothing.
points Every nothing is identified correctly. All or nothing.
points The Python solution is properly commented, easy to understand, high quality and does not contain unnecessary code. points for each type of improvement up to points.
Python Poker 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
example output:
hand "clubs" "clubs" "clubs" "clubs" "clubs" # 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 "hearts" "hearts" "hearts" "hear
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started