please name this cards.py. You may use the following code in your program: import random SUITS = "♠ ♡ ♢ ♣".split() RANKS = "2 3 4 5 6 7 8 9 10 J Q K A".split() def create_deck(shuffle=False):     """Create a new deck of 52 cards"""     deck = [(s, r) for r in RANKS for s in SUITS]     if shuffle:         random.shuffle(deck)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

please name this cards.py.

You may use the following code in your program:

import random

SUITS = "♠ ♡ ♢ ♣".split()
RANKS = "2 3 4 5 6 7 8 9 10 J Q K A".split()

def create_deck(shuffle=False):
    """Create a new deck of 52 cards"""
    deck = [(s, r) for r in RANKS for s in SUITS]
    if shuffle:
        random.shuffle(deck)
    return deck


This code creates a random deck of cards (each card is a tuple consisting of a rank and 
suit).  You are to ask the user how many 5-card hands to play and will keep track of the 
following poker hands.  You will need to reshuffle the deck as many times as necessary to get the required number of hands.  

An example run of the program is as follows.

Enter the number of hands to deal: 10000
Hand          % of Hands  Hands of Type
2 of a kind    41.290%    4129      
3 of a kind     1.970%    197       
4 of a kind     0.010%    1         
2 pair          4.860%    486       
Full house      0.150%    15        
Flush           0.220%    22        

If you deal enough hands the percentage for each hand should approach the values shown in the table on this page.

Since this is a harder assignment, I would suggest you start with determining if a hand is a flush (all cards of the same suit). I will give more credit for printing the percentage of more of the hands. You can also add the results for straights, straight flushes and royal flushes if you want, which will earn you extra credit points. I am also giving extra credit for using list comprehensions in the solution.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education