1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zubka84 [21]
3 years ago
11

Write a function flush that takes as input a list of five cards, tests whether it is a flush (Note: straight flush is not a flus

h!) and return a boolean value. If the entry is anything other than five distinct cards, it should return (not print!) the message "This is not a valid poker hand".
Computers and Technology
1 answer:
melamori03 [73]3 years ago
5 0

Answer:

Explanation:

ef poker(hands):

   scores = [(i, score(hand.split())) for i, hand in enumerate(hands)]

   winner = sorted(scores , key=lambda x:x[1])[-1][0]

   return hands[winner]

def score(hand):

   ranks = '23456789TJQKA'

   rcounts = {ranks.find(r): ''.join(hand).count(r) for r, _ in hand}.items()

   score, ranks = zip(*sorted((cnt, rank) for rank, cnt in rcounts)[::-1])

   if len(score) == 5:

       if ranks[0:2] == (12, 3): #adjust if 5 high straight

           ranks = (3, 2, 1, 0, -1)

       straight = ranks[0] - ranks[4] == 4

       flush = len({suit for _, suit in hand}) == 1

       '''no pair, straight, flush, or straight flush'''

       score = ([1, (3,1,1,1)], [(3,1,1,2), (5,)])[flush][straight]

   return score, ranks

>>> poker(['8C TS KC 9H 4S', '7D 2S 5D 3S AC', '8C AD 8D AC 9C', '7C 5H 8D TD KS'])

'8C AD 8D AC 9C'

You might be interested in
All of the following items could be too expensive for someone with only a high school degree to afford except
Papessa [141]
This sounds like a multiple choice answer can I have 4 choices to pick?
7 0
3 years ago
Your new home has a vacuum system. what kind of computer is controlling it?
Scrat [10]
The answer is embedded computer. It is a PC framework with a committed capacity inside a bigger mechanical or electrical framework, frequently with ongoing figuring constraints. It is implanted as a component of a total gadget regularly including equipment and mechanical parts. Installed frameworks control numerous gadgets in like manner utilize today.
6 0
3 years ago
These data provides the responses of 10 students in class A and in class B who were asked how many hours they slept lastThese da
dmitriy555 [2]

Answer:

Answer C

Explanation:

Class A Median: 4, 5, 6, 6, 7, 7, 7, 7, 8, 8

The Median of Class A is 7.

Class B Median: 5, 6, 6, 6, 7, 7, 7, 8, 8, 9

The Median of Class B is 7.

Class A Mean: 4 + 5 + 6 + 6 + 7 + 7 + 7 + 7 + 8 + 8 = 65

To find the mean, you add all of the numbers together, and divide the total by the amount of numbers. (There are ten numbers in the equation, so we divide 65 by 10.)

65/10 = 6.5, This means that the mean of Class A is 6.5

Class B Mean: 5 + 6 + 6 + 6 + 7 + 7 + 7 + 8 + 8 + 9 = 69

Do the same thing as last time, divide 69 by 10. (6.9)

The mean of class B is 6.9

Answer A and B are both incorrect, because the medians for both classes were the same.  Answer C is correct, because the mean of class B was 6.9 and the mean of Class A was 6.5

Answer D is also incorrect, 6.9 is 0.4 greater than 6.5

Solved by Inspire! (14 years old)

3 0
3 years ago
Directions for starting the computer and opening a word processor document
aleksandr82 [10.1K]
First you download word after you open a page  and you start 
4 0
3 years ago
Pros and cons of access to a wide range of online services when it comes to an individual's safety?
Contact [7]
Talk about cyber bullying but also all of the advancement and conviences of technology
Hope that helps
6 0
3 years ago
Other questions:
  • How many times do you usually use npm?<br> Put your answer in the box.
    6·1 answer
  • In addition to training on the products and on company policy, it does not make sense to be prepared to speak about your company
    6·2 answers
  • When you align or size a group of selected controls, the changes are made relative to the
    14·1 answer
  • The feature present in most GUIs that helps organize multiple documents or files is _____.
    5·1 answer
  • Randy earn $22 per hour. This is an example of
    11·1 answer
  • Fill in the blank with the correct response.
    10·1 answer
  • Explain how computer system is different from computer in 150 words
    14·1 answer
  • Karl comes across confidential information. What should he do with it? A. Manipulate the information in his favor B. Sell the in
    12·1 answer
  • 6. Python indexes lists beginning with the number 1.<br> True<br><br> False
    15·1 answer
  • Another name of computer program is
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!