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
Your marketing director at ABC Marketing Agency would like to set up an email campaign that will use personalization to referenc
Brilliant_brown [7]

Answer:

Yes, it is very possible for leads. Before you can call someone or an organization a lead, you must have received several information from them, which includes name and other essential information. Hence, a personalization can be used to reference a lead's recent conversion in an email campaign if required.

Explanation:

8 0
3 years ago
What kind of java program runs within a java-enabled browser?
ankoles [38]
An applet.





_____________
5 0
3 years ago
When you move a paragraph in a document that includes text with a footnote, what happens to the footnote reference?
kumpel [21]

How it is supposed to work is that provided the footnotes were inserted correctly using the Reference tab and then click on insert footnote, then these notes will also be moved with the text. As long as the selection includes the footnote reference in the text, moving the text will also move notes as well.

3 0
3 years ago
Read 2 more answers
In cell F15, insert a function that will automatically display the word Discontinue if the value in cell D15 is less than 1500,
777dan777 [17]

Answer:

=IF(D15<1500, "Discontinue", "No Change")

Explanation:

Assuming that this is excel, you can locate the cell F15 and input the IF function. The formula for IF function is

IF(<condition>, <action if true>, <action if false>)

So before the 1st comma, we place the condition which is D15 < 1500

In the middle, before the 2nd comma, we place the text to display if D15 is less than 1500, which is "Discontinue".

In the last place, we place the text to display if D15 is greater than or equals to 1500, which is "No Change"

So the overall formula is =IF(D15<1500, "Discontinue", "No Change")

3 0
3 years ago
DES: Group of answer choices A) is a commonly used symmetric encryption B) algorithm that was developed in the mid-C) 1970s was
OLEGan [10]

DES is a commonly used symmetric encryption

A) is a commonly used symmetric encryption

<u>Explanation:</u>

DES stands for Data Encryption Standard. It is a symmetric key algorithm and is used for encrypting electronic data. It was developed in 1975. DES is one of the oldest encryption standards to be used in the industry.

The algorithm takes 16 rounds of permutations in order to encrypt data. But now, with the advent of technology, as new algorithms have been designed and put in use, DES is less preferable.

In the process of key generation, some keys generated sometimes turn out to be weak and hence are prone to attacks. If not for the weak keys generation, DES works perfectly fine and is an effective algorithm to encrypt data.

6 0
3 years ago
Other questions:
  • What processes are needed to transform a c++ program to a machine language program that is ready for execution?
    14·1 answer
  • What is the use of form in HTML​
    12·1 answer
  • After adding an email account, how do you switch accounts to send a message?
    10·2 answers
  • Write a function named firstLast2 that takes as input an array of integers and an integer that specifies how many entries are in
    14·1 answer
  • A technician wants to consolidate and log specific alerts from network devices into a database so maintenance tasks and potentia
    11·1 answer
  • Which statement is true about the purpose of a work in process constraint?
    15·1 answer
  • At each layer of the OSI model, data is appended to the original message and then sent on to the next lower layer. What is this
    10·1 answer
  • Breaking code rules is only a problem once in a while. Group of answer choices True False
    12·1 answer
  • When you expect a reader of your message to be uninterested, unwilling, displeased, or hostile, you should Group of answer choic
    15·1 answer
  • What happens when text is added to grouped objects that is larger than an object ?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!