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
How is a ink pen better than a digital pen.
Hatshy [7]
It depends on what digital pen you're using.
Ink pens are better because they don't run out of ink like digital and you dont have to re-charge every time.
Hope this helps!:)<span />
8 0
3 years ago
The expression 10,785(1.0275)x represents the amount of money in an investment account with interest that compounds annually for
Kamila [148]

E

According to the question,

The amount of investment money is $10,785 and the rate of interest is 1.0275%. The amount of money will be multiplied with the rate of interest and the year.

To get future value of the investment it will be like

FV = PV(1+i)x

Therefore , Future value = 10,785(1.0275)x

8 0
3 years ago
Read 2 more answers
Instead of terminating the series, the producers decided to extend it for an additional season. In the sentence above, which of
Leya [2.2K]
I believe it would be "Use the context to find a synonym for terminating." (Also next time try posting in the English section :) )
6 0
4 years ago
Write a program that reads in 10 numbers from the user and stores them in a 1D array of size 10. Then, write BubbleSort to sort
Diano4ka-milaya [45]

Answer:

The solution is provided in the explanation section.

Detailed explanation is provided using comments within the code

Explanation:

import java.util.*;

public class Main {

//The Bubble sort method

public static void bb_Sort(int[] arr) {  

   int n = 10; //Length of array  

   int temp = 0; // create a temporal variable  

   for(int i=0; i < n; i++){  

         for(int j=1; j < (n-i); j++){  

           if(arr[j-1] > arr[j]){  

               // The bubble sort algorithm swaps elements  

               temp = arr[j-1];  

               arr[j-1] = arr[j];  

               arr[j] = temp;  

             }  

         }            

         }  

        }

 public static void main(String[] args) {

   //declaring the array of integers

   int [] array = new int[10];

   //Prompt user to add elements into the array

   Scanner in = new Scanner(System.in);

   //Use for loop to receive all 10 elements

   for(int i = 0; i<array.length; i++){

     System.out.println("Enter the next array Element");

     array[i] = in.nextInt();

   }

   //Print the array elements before bubble sort

   System.out.println("The Array before bubble sort");

   System.out.println(Arrays.toString(array));

   //Call bubble sort method

   bb_Sort(array);  

               

   System.out.println("Array After Bubble Sort");  

   System.out.println(Arrays.toString(array));

 }

}

8 0
3 years ago
Select the correct answer.
SpyIntel [72]

Answer:

i think real time fluid dynamics

Explanation:

3 0
3 years ago
Other questions:
  • Which of the following can be both an input device and an output device? mouse. keyboard. display screen. laser printer .
    9·1 answer
  • For this exercise, you'll use the Rectangle class below (you can assume that the length and width are measured in feet).
    12·1 answer
  • What type of engineer is interested in designing, developing, and building different machines, devices, and tools? A.aerospace
    8·2 answers
  • Your ___ can provide hardware firewall protection for your home network where it connects to the ISP's network, just as ISP netw
    12·1 answer
  • 2) A simple operating system supports only a single directory but allows it to have arbitrarily many files with arbitrarily long
    7·1 answer
  • Which of the following is constantly changing and advancing?
    11·1 answer
  • While developing a network application, a programmer adds functionally that allows her to access the running program without aut
    14·1 answer
  • Write a program that allows the user to enter their name from the keyboard. Allow the user to pick how many times they want thei
    12·1 answer
  • The software that displays the resulting web pages is​
    9·1 answer
  • You are developing a Website that is going to be viewed extensively on smartphones and tablets. Which of the following should yo
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!