Question: PYTHON A card is a tuple containing a number between 1 and 13 representing the cards value and a string containing clubs, diamonds, hearts, or

PYTHON

A card is a tuple containing a number between 1 and 13 representing the cards value and a string containing "clubs", "diamonds", "hearts", or "spades". Thus the ace of spaces would look like (1, "spades") and the king of diamonds (13, "diamonds") A deck is a list of 13 cards.

Your program should create a deck of cards, shuffle it, and then put the first five cards in the deck into a 5 element list which represents a hand.

You should write a series of functions which return boolean values that can be used to analyze this hand.

def is_pair(hand): should return true if there are exactly 2 cards of the same value

def is_2_pair(hand): should return true if there is one set of 2 cards with a common value and a second set of 2 cards with a different common value

def is_3_ofakind(hand): returns true if there are exactly 3 cards with a comrmon value

def is_full_house(hand): returns true if there are 3 cards with a common value and the other cards share a different common value

def is_flush(hand): if the five cards all have the same suit

def is_straight(hand): returns true if the value of the five cards form a sequence which increases by 1 in each case. For instance (2,"hearts"). (3,"spades"), (4, "diamonds"), (5,"hearts"), (6,"clubs")

Your program should create a deck, shuffle it, create a hand from the first five cards, then call each of the above functions and print out which of them return True.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!