Question: Please use python 3! Thanks! we'd like to recognize whether a hand contains a certain number of matching ranks or suits. Implement the following functions

Please use python 3! Thanks!  Please use python 3! Thanks! we'd like to recognize whether a

we'd like to recognize whether a hand contains a certain number of matching ranks or suits. Implement the following functions has 3kind (hand) should return True if a hand has 3 cards with the same rank (three-of-a-kind"), and Fal se otherwise. hasflush (hand) should return True if a hand has 5 cards with the same suit (a "iush"), and Palse otherwise (Hint: you should start by spltting each card into a rank and a suit. Remember, you can treat strings like lists and uses slices and indexing on them The unicode suits above behave a little strangely, so test what your slices give you... (Make sure your code deals properly with 10, which has an extra character compared to the other ranks) Another hint: as we've seen, np.unioue is very useful for counting how many instances there are of all discrete values in a ist) def has 3kind Chand): a hand[ return True test hand 2K K+K test hand 3-10104, K2' test hand4-3 print (has 3kind(test hand 1)) assert has 3kind(test hand 1) assert has 3kind (test hand 2) assert has 3kind(test hand 3) print (has flush(test hand 4))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!