Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Rank Description Example Straight flush Three suited cards in sequence Three of a kind Three cards of same rank Straight Three cards in sequence

image text in transcribedimage text in transcribed

image text in transcribed

image text in transcribed

python

Rank Description Example Straight flush Three suited cards in sequence Three of a kind Three cards of same rank Straight Three cards in sequence Flush Three suited cards Pair Two cards of same rank High card None of the above Guidelines Think carefully about the order you will check different properties. You might want to write some pseudocode or perhaps draw a flowchart if this works better for you. Think first, then implement Be careful what kinds of selection statements you use, and be sure to test your code with many examples. For instance, multiple if statements will not necessarily behave the same as a chain of if-elif-elif. When a specific test case isn't working, plug your code into the visualizer to watch what the code does, which lines run, which branches are taken. From built-in functions, you are allowed to call abs(), int(), float(), str() only You are not allowed to import anything. You are not allowed to use loops, lists, sets, dictionaries and any feature that hasn't been covered in class yet Don't forget to review the "assignment basics" file Insert comments in the lines you deem necessary Your task is to implement for each of these hands one function that takes three parameters (numbers that represent the three cards) and returns a boolean value. True or False, depending on whether the three cards make up the respective hand or not. We will use the Table 2 mapping to represent the standard 52 card deck with integers. Ace will always rank low i.e. be the lowest card when considering a sequence for straight) Ace 2 3 4 5 6 7 8 9 10 Jack Queen King 2 3 4 5 6 7 8 9 10 11 12 Diamonds 14 15 16 17 18 19 20 21 22 23 24 25 Hearts Het ERREPIK22. 27 28 29 30 31 32 33 34 35 36 37 38 Spades 40 41 42 43 44 45 46 47 48 49 50 51 Table 2 Assumptions You may assume that: The types of the values that are sent to the functions are the proper ones (cardi is an integer not a float, etc.), you don't have to validate them. The functions are going to be called with usable values (e.g. cardi is not negative, etc.). you don't have to validate them. All function parameters are guaranteed to be unique, you don't have to validate them either. Functions The signature of each function is provided below, do not make any changes to them otherwise the tester will not work properly. Keep in mind that you must not write a main body for your program. You should only implement these functions; it is the tester that will be calling and testing each one of them. The following are the functions you must implement: straight flush(cardi, card2, card3) Description: The function checks whether the three cards make up a straight flush hand, and only that Parameters cardi (int), card2 (int), card (int) are the three cards represented with the mapping provided in Table 2. Return value True or False Examples straight flush(2, 1, 3) + True three_of_a_kind (cardi, card2, card3 ) Description: The function checks whether the three cards make up a three of a kind hand, and only that Parameters cardi (int), card2 (int), card3 (int) are the three cards represented with the mapping provided in Table 2 Return value True or False Examples: three_of_a_kind (14, 27, 1) True straight (cardi, card2, card3) Description: The function checks whether the three cards make up a straight hand, and only that Parameters cardi (int), card2 (int), card3 (int) are the three cards represented with the mapping provided in Table 2 Retum value True or False Examples straight (34, 33, 35) . False = straight flush flush(cardi, card2, card3) Description: The function checks whether the three cards make up a flush hand, and only that. Parameters: cardi (int), card2 (int), card3 (int) are the three cards represented with the mapping provided in Table 2

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

More Books

Students also viewed these Databases questions

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago