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
From where do we get information or knowledge? Explain.
Tems11 [23]

Answer:

the explanations is down here,

Explanation:

Information

Data reaches a more complex level and becomes information by integrating them to a context. Information provides expertise about facts or persons. Example of information: The information about a date of birth still has very little value when it is unknown to which person it belongs. By adding more information like the name, the linked information creates knowledge about a person.

Knowledge

Knowledge thus describes the collected information that is available about a particular fact or a person. The knowledge of this situation makes it possible to make informed decisions and solve problems. Thus, knowledge influences the thinking and actions of people. Machines can also make decisions based on new knowledge generated by information. In order to gain knowledge, it is necessary to process information.

7 0
3 years ago
Read 2 more answers
Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate l
Montano1993 [528]

Answer:

The program in Python is as follows:

num = int(input())

for i in str(num):

   print(int(i))

Explanation:

This gets input for the number

num = int(input())

This converts the number to string and iterates through each element of the string

for i in str(num):

This prints individual digits

   print(int(i))

4 0
3 years ago
How to get on website?
Nitella [24]

Answer:

You are probably blocked from that website or your schools program blocks that website from your device

Explanation:

4 0
3 years ago
How do you put a fraction into a computer countulater
ad-work [718]

Answer:

i have no clue sorry:(

Explanation:

I didn't do this to get points i promise

3 0
3 years ago
Read 2 more answers
To join a social network you create an avatar true or false
svp [43]
False because not all social media webstites provide avatars
7 0
3 years ago
Read 2 more answers
Other questions:
  • Select five system utility functions.
    11·1 answer
  • What is the difference between a rendering engine and a browser engine?
    5·2 answers
  • A computer is defined by 4 specific criteri. Select all 4.*
    7·1 answer
  • Integration Management, one of the 10 PMBOK Guide Knowledge Areas, represents the processes and activities to identify, define,
    12·1 answer
  • NEED THIS NOW PLEASE!!!! (I AM NOT JOKING I HAVE TO SUBMIT IN 5 MINUTES)
    13·2 answers
  • Which tool is used to view stars in galaxies far from the Milky Way?
    10·1 answer
  • Using a single formatting _______ helps to make reading researched information easier; it lets the reader know what to expect.
    7·1 answer
  • An alteration threat violates information integrity. <br> a. True <br> b. False
    13·1 answer
  • The foundation of secure communication on the internet replies on asymmetric encryption, with the use of Public and Private keys
    10·1 answer
  • 100 POINTS!!!!!!
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!