Data Collections

Your Assignment

Your understanding of importing modules, using lists and dictionaries and creating objects from a class will be exercised in this lab.

Be prepared to use your solution for the Classes lab where you wrote the PlayingCard class.

In this lab, you will have to generate a random list of PlayingCard objects for where the suit and rank combinations of each card are randomly choosen. Using this list of randomly created playing cards, you will use dictionaries and lists to store important data about these playing cards, particularly the frequency distribution of each rank-suit combination you created (e.g. like if 10 queen of hearts cards are generated and counted.)

Thanks to the clearly described interface used to communicate to any PlayingCard object, specifically the get_rank() and get_suit() methods, you can just import your “Classes” lab as a module and use your previously written code!

Note: You’ll definitely need to make sure your solutions work for this lab, and if not, please consult the professor or TAs for assistance, ASAP.

  1. I provide a starter (skeleton) code file for your solution. You are required to use it. Download and complete it with your code.

  2. Your lab assignment requires the use of your solution from the Classes lab. You will import your code as a module and use your PlayingCard class.

    The skeleton code includes the necessary import line, just provide your file by placing a copy of your file in the same directory as your solution code for this lab.

  3. The docstrings inside this file describe what each function should do.

  4. Replace and complete missing code wherever you see::


    Do not change anything else like function names, parameters or return values. Do not remove the if statements at the start of some functions as they are needed to make sure you are passing the correct values. You will lose points you if you change anything you are not supposed to change.


This is what you should see (your numbers will be different):

Standard deviation for the frequency counts of each rank in suit:
        Hearts:  2.3755 cards
        Spades:  1.1242 cards
        Clubs:  1.4880 cards
        Diamonds:  1.5607 cards

Submission Requirements

Your file is required to be named

Please read and follow the Submission Requirements to avoid point deductions specified below.


The following is the grading rubric for this lab to be used by the course graders. The lab is worth 100 points.

Note: There may be additional criteria for grading, this is just a summary of the major rubric items.

Grading Rubric
Type Description Point Loss (Max)
SyntaxError Exceptions A program that doesn’t even start due to syntax errors. -30
Docstrings Missing proper lab header (e.g. no name, lab section, etc) -10
main() Your program should have main() as the first-called function -10
PEP 8 Style Egregious problems with your code styling -10
Incorrect Filename Follow the submission instructions -5
Commenting Insufficient or excessive comments -5
  [Lab Specific]  
Import Your solution must import, and use your PlayingCard class. -15
Dictionaries The solution must use Python dictionaries to manages information inside your class -25
Skeleton Code The skeleton code provided should not be modified except the sections I specifically allow for modification. -10 points/each infraction