GT Students

Introduction

In this assignment you’ll practice

General Instructions

This is an individual assignment.

Collaboration at a reasonable level will not result in substantially similar code. Students may only collaborate with fellow students currently taking CS 2316, the TA’s and the lecturer. Collaboration means talking through problems, assisting with debugging, explaining a concept, etc. You should not exchange code or write code for others.

Notes:

Problem Description

You are writing a web application to manage a database of Georgia Tech students.

Solution Description

Write a module named gtstudents with the classes and functions specified below.

Required Classes and Functions

Classes

GtStudent

Write a class called GtStudent with the following instance variables:

These instance variables should all be initialized when you create an instance of GtStudent.

In addition, implement the following methods:

Functions

mk_gtstudents_dict

Write a function called mk_gtstudents_dict which takes a list of GtStudent instances and returns a dictionary mapping GT IDs to the GtStudent instance having that GT ID. If more than one GT ID appears in the list, the subsequent instances may replace earlier ones.

graduating

Write a function called graduating which takes a dictionary mapping GT IDs to GtStudent instances (like the one returned by mk_gtstudents_dict) and returns a list containing all the instances of GtStudent with more than 115 hours.

doctest

Include the docstring below as a module docstring in your gtstudents module so that you can test your code using the doctest module.

python -m doctest -v gtstudents.py

If all the tests pass, then you’ll have a good chance of getting a 100 on this homework. Take a look at these docstests. Are there any edge cases that aren’t tested?

IMPORTANT: The provided doctstrings test the code for the output we expect. If you change these docstrings they may not test your code the way we will test it. We engourage you to add your own docstrings, but we recommend that you leave these docstrings as-is.

>>> import datetime as dt
>>> cartman = GtStudent("123456789", "ecartman3", "Eric", "Cartman", dt.date(2009, 7, 1), "BA", 80)
>>> kenny = GtStudent("223456789", "kmccormick3", "Kenneth", "McCormick", dt.date(2009, 4, 10), "STAC", 80)
>>> stan = GtStudent("323456789", "smarsh3", "Stanley", "Marsh", dt.date(2009, 10, 19), "IE", 85)
>>> kyle = GtStudent("423456789", "kbroflovski3", "Kyle", "Broflovski", dt.date(2009, 5, 26), "CS", 85)
>>> cartman
<Eric Cartman (123456789, ecartman3), a 9 year-old 3rd-year BA major>
>>> str(cartman)
'<Eric Cartman (123456789, ecartman3), a 9 year-old 3rd-year BA major>'
>>> stan == kyle
False
>>> stan2 = GtStudent("323456789", "smarsh3", "Stanley", "Marsh", dt.date(2009, 10, 19), "IE", 85)
>>> stan is stan2
False
>>> stan == stan2
True
>>> cartman < kenny
True
>>> stan < kenny
False
>>> cartman.age()
9
>>> cartman.year()
3
>>> boys = [cartman, kenny, stan, kyle]
>>> boys_dict = {"123456789": cartman, "223456789": kenny, "323456789": stan, "423456789": kyle}
>>> mk_gtstudents_dict(boys) == boys_dict
True
>>> bebe = GtStudent("987654321", "bstevens3", "Barabara", "Stevens", dt.date(2009, 5, 5), "EE", 116)
>>> heidi = GtStudent("887654321", "hturner3", "Heidi", "Turner", dt.date(2009, 6, 2), "PHYS", 117)
>>> annie = GtStudent("787654321", "aknitts3", "Annie", "Knitts", dt.date(2010, 1, 25), "ME", 115)
>>> wendy = GtStudent("687654321", "wtestaburger3", "Wendy", "Testaburger", dt.date(2009, 10, 2), "AE", 114)
>>> girls = [bebe, heidi, annie, wendy]
>>> graduating(mk_gtstudents_dict(boys + girls))
[<Barabara Stevens (987654321, bstevens3), a 9 year-old 4th-year EE major>, <Heidi Turner (887654321, hturner3), a 9 year-old 4th-year PHYS major>]
>>> try:
...      mk_gtstudents_dict([cartman] + boys)
... except Exception as e:
...     print(str(e))
...
Multiple students with 123456789

Tips and Considerations

Grading

Turn-in Procedure

Submit your gtstudents.py file on Canvas as an attachment. When you’re ready, double-check that you have submitted and not just saved a draft.

Verify the Success of Your Submission to Canvas

Practice safe submission! Verify that your HW files were truly submitted correctly, the upload was successful, and that your program runs with no syntax or runtime errors. It is solely your responsibility to turn in your homework and practice this safe submission safeguard.