# -*- coding: utf-8 -*-
# class_dictionary.py
# MIT OCW 6.189 Homework 3
# Exercise 3.3 – An Introduction to Dictionaries
# Mechanical MOOC
# Judy Young
# July 23, 2013

# For this exercise, write a dictionary that catalogs the classes you took last term 
# - the keys should be the class number, and the values should be the title of the class.
# Then, write a function add class thattakes 2 arguments- a class number and a description 
# - that adds new classes to your dictionary. Use this function to add the classes you’re taking 
#   next term to the dictionary.
# Finally, write a function print classes that takes one argument 
# - a Course number (eg ’6’) - and prints out all the classes you took in that Course.

class_dictionary = {'6.002': 'Circuits and Electronics', '6.042J': 'Mathematics for Computer Science', '6.102': 'Introductory RF Design Laboratory', '8.033': 'Relativity' , '8.226': 'Forty-three Orders of Magnitude', '15.072J': 'Queues: Theory and Applications'}

def add_class(class_number, description):
    class_dictionary[class_number] = description
    print class_number, "-", description, "ADDED"

def remove_class(class_number):
    stash = class_dictionary[class_number]
    del class_dictionary[class_number]
    print class_number, "-", stash, "REMOVED"

# prints all classes give a course number                         
def print_classes(course_number):
    total_classes = 0
    for classes in class_dictionary:
        if classes[0] == course_number:
            print classes, "-", class_dictionary[classes]
            total_classes += 1
    if total_classes == 0:
        print "No Course", course_number, "classes taken"

# print all classes, no limits
def print_all_classes():
    print "\n\nAll Classes\n-----------"
    all_classes_grouped = sorted(class_dictionary.keys())
    for each in all_classes_grouped:
        print each, "-", class_dictionary[each]
    print "\n"


print_all_classes()

add_class('4.109', 'ProtoArchitecture')
add_class('15.082J', 'Network Optimization')
add_class('4.171', 'Design Workshop: The Space Between ')
add_class('6.182', 'Psychoacoustics Project Laboratory')
add_class('6.254', 'Game Theory with Engineering Applications ')
add_class('6.805', 'Ethics and the Law on the Electronic Frontier')
remove_class('6.002')

print_all_classes()

print "\nAll my EECS classes\n-------------------\n", print_classes("6")
print "\nAll my PoliSci classes\n---------------------\n", print_classes("17")