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
Is the ability to choose the start and finish times, but they must complete a full day’s work
Hatshy [7]
Yes ma’am , can of spam. what she said up there ^*
4 0
3 years ago
Which are the common database operations that can help organize data for easy retrieval?
Dima020 [189]

There are two common types for data access or retrieval

1. Sequential access is the main access mode only in batch systems, whereas files are used and updated at regular intervals.

2. Direct access - on-line processing requires direct access, whereby a record can be accessed without accessing the records between it and beginning of the file.

7 0
4 years ago
How do people interact with chromebooks
geniusboy [140]

It is a laptop so they are able to take them with them whit them they are the most potable laptop able over any apple product you can get in the same category

8 0
3 years ago
Read 2 more answers
To track what level a player is on, you can create a simple variable and a block saying change level by 1 attached to the when g
marishachu [46]

Answer:

False

Explanation:

I did it on edgnuity also i got it right

5 0
3 years ago
Edmentum Plato Course - Learning in A Digital World: Strategies for Success
jeyben [28]

Answer:

A

Explanation:

The information was written recently or has been updated recently.

6 0
3 years ago
Other questions:
  • It is appropriate to leave sections of an application blank ?<br><br><br><br> True or False
    7·1 answer
  • On the UB-04 claim form, the type of bill is identified by a four-digit numerical code. The first digit is a leading zero, what
    10·1 answer
  • Which feature does the web designer fail to apply in this layout for a web page? A. harmony
    8·2 answers
  • Respecting yourself and others, educating yourself and connecting with others, and protecting yourself and others are all aspect
    11·1 answer
  • A technician suspects a network card is not working. Which tool should the technician use to test the network card?
    8·1 answer
  • Apple's macOS and Microsoft Windows are examples of ________ software. utility application communication operating system
    13·1 answer
  • Create a Python script that takes two parameters to do the following:-
    9·1 answer
  • What are the advantages to using a linked implementation as opposed to an array implementation?
    8·1 answer
  • Which of the following is NOT present on the Title Bar?​
    7·1 answer
  • OMG 2 TIMES ;DDDDDDDDDDDDDDDDD​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!