Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using a python program create a deck of cards. A card is a tuple containing a number between 1 and 13 representing the cards value

Using a python program

create a deck of cards. A card is a tuple containing a number between 1 and 13 representing the cards value and a string contianing "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 funcitions 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

=+and non-compete agreements in three to five different countries.

Answered: 1 week ago