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
What is microsoft certification?
BabaBlast [244]
Microsoft certification is a series of programs that provide certification of competence in Microsoft products.
6 0
3 years ago
When creating loyal customers you must develop all of the following except: a. Smooth relationships b.customer marketing c. Dedi
bixtya [17]

Answer: I think a

Explanation: sorry I’m in wrong, have a great day!! :D

7 0
3 years ago
Read 2 more answers
What is networking??????????????????????
kodGreya [7K]

Answer:

the activity or cycle of collaborating with others to trade data and create proficient or social contacts.

Explanation:

<3

8 0
3 years ago
You are building your own computer, and you are ready to select
KiRa [710]

Answer:

D

Explanation:

It's because you need a system software so the user can understand what the hardware is saying because the hardware only uses binary codes.

7 0
2 years ago
Should spreadsheets be used to capture the results of a science experiment?<br><br> YES<br> NO
Lyrx [107]

Answer:

Yes

Explanation:

Spreadsheets should be used to capture the results of science experiments because they are good for sorting data. They make results easier and information easier to see and use.

3 0
2 years ago
Read 2 more answers
Other questions:
  • DSL technology is less efficient for service providers in the United States because many of their customers live in less-densely
    11·1 answer
  • The ____________ mechanism consists of a lever arm attached to the mousetrap spring.
    15·1 answer
  • You would like to conduct a survey and ask your web page visitors to indicate the computer operating systems that they use. Each
    10·1 answer
  • What's the difference between intranet and extranet ​
    9·1 answer
  • Which HTML tag is used to add a paragraph to a web page?
    15·1 answer
  • The function below takes a single argument: data_list, a list containing a mix of strings and numbers. The function tries to use
    6·1 answer
  • If cells A1=90,A2=85,A3=80,A4=75, A5=75.What will be the formula if you are going to get the formula total
    5·1 answer
  • Which activity is the best example of a negative habit that may result from
    12·1 answer
  • 2. How much did John Jones have in his account on the first day of the
    5·1 answer
  • What is System Testing
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!