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.

Assignment Requirements

  1. I provide a starter (skeleton) code file for your solution. You are required to use it. Download lab_data_collections.py 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 lab_classes.py 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::

    #
    # REPLACE WITH YOUR CODE.
    #
    

    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.

Sample Output

Using the simple set of test, above, 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

There are a few standards to adhere to when submitting your lab. Please read, and follow them carefully.

  1. Submission Filename: Submit a file named lab_data_collections.py.

  2. Documentation String (“docstring”): The following docstring (properly edited with your name) needs to be the very first thing in your Python program file.

    """CSC 161 Lab: Data Collections
    
    This lab...
    
    Fox Mulder
    Lab Section TR 2:00-3:15pm
    Fall 2015
    """
    

    Read more about docstrings: Program Documentation String

  3. Comments (lines prefaced with #): Unclear parts of your code can receive point deductions, so be judicious about using comments. Do not overuse comments. Too much unnecessary commenting can complicate reading otherwise clear code!

    Read more about comments: Program Comments

  4. Python Code Style: You will need to run your Python program file through the online PEP 8 style checker found in CSC 161 Style.

  5. The __main__, top-level script environment” check is required:

    if __name__ == '__main__':
        main()
    

    You can read more about this trick on the official Python website.

The Blackboard post for this lab assignment will contain the details regarding the due date and other details regarding class administration for this assignment.

Grading

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

Here’s a brief grading rubric:

Generally:
  • Syntax errors: -30 points
  • A bad/missing docstring (i.e. no name, lab section, etc): -10 points
  • The submitted filename is wrong: -10 points
  • No Python comments used when they are needed to clarify code: -5 points
  • Code doesn’t attempt to adhere to Python coding style: -10 points
  • Your top-level script environment check is missing: -5 points
  • Missing main() function: -10 points
Assignment-specific:
  • Your assignment must minimally run the tests given in this assignment description. You can add more of your own, however. If the given tests are missing: -5 points
  • The solution must import lab_classes.py and use your PlayingCard class: otherwise, up to -15 points.
  • The solution must use Python dictionaries to manages information inside your class: otherwise, up to -25 points.
  • The skeleton code provided should not be modified except the sections I specifically allow for modification: otherwise, any change may receive up to -10 points for each infraction.

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

Extra Credit

You are allowed to add something creative and interesting to your program for extra credit:

  1. You are not guaranteed to receive extra credit, it will be up to the lab TA to decide.
  2. Any extra credit work you do needs to be clearly commented in your code - Otherwise, you are not guaranteed to receive extra points.
  3. Do not submit a second Python file, just modify your original submission.
  4. Extra credit supersedes any of the above grading rubric if it conflicts.