# -----------------------------------------------------------------------------
# Name:        college
# Purpose:     class definitions for a college environment
#
 # Author:     Raymond Cabrera
#
# Date:  2/21/16
# -----------------------------------------------------------------------------
"""
Module to describe a college setting.

"""
class Person(object):

    """
    Represent a person affiliated with the college: student, faculty or staff

    Arguments:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address - defaults to the empty string

    Attributes:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address
    """

    def __init__(self, name, cid, email = ''):
        self.name = name
        self.cid = cid
        self.email = email

    def __str__(self):
        result = ('NAME: ' + self.name + '\n' +
                'ID: ' + str(self.cid) + '\n' +
                'EMAIL: '  + self.email)
        return result


class Student(Person):
    """
    Represent a Student in a college environment

    Arguments:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address - defaults to the empty string

    Attributes:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address
    courses (string): student's current and previous courses - dictionary keys
    grades (int): student's grades for corresponding courses on a 0-4 scale
                  - dictionary values
    gpa (float): student's grade point average - property method
    """

    def __init__(self, name, cid, email=''):
        self.courses = {}
        self.grades = 0
        super().__init__(name, cid, email)

    def add_course(self, course):
        """
        Add a course to a student's schedule

        Parameter:
        course (string): course (key) to be added to the course dictionary,
                         with an initial grade of 0 (value). If the student is
                         already enrolled in the course, a NameError is raised.
        Returns: updated Student object
        """
        if course in self.courses:
            raise NameError('This student is already enrolled in that course')
        else:
            self.courses[course] = 0

        return self

    def update_grade(self, course, grade):
        """
        Add a corresponding grade to a student's course

        Parameter:
        course (string): course (key) in the 'courses' dictionary that needs an
        updated grade (value)
        grade (integer): grade of corresponding course on a scale of 0-4
        Returns: updated Student object
        """
        if course not in self.courses:
            raise NameError('This student is not enrolled in that course')
        else:
            self.courses[course] = grade

        return self



    @property
    def gpa(self):
        """
        Calculates a Student's grade point average.

        If a student is not enrolled in any courses, return 0. Otherwise,
        return a student's gpa (float) which is the sum of the student's grades
        divided by the number of registered courses
        """
        try:
            return sum(self.courses.values()) / len(self.courses)
        except ZeroDivisionError:
            return 0

c9340f3827d94d82e77a2f108bdd8ad874494a3e
<mask token>


class Person(object):
    <mask token>
    <mask token>
    <mask token>


class Student(Person):
    """
    Represent a Student in a college environment

    Arguments:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address - defaults to the empty string

    Attributes:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address
    courses (string): student's current and previous courses - dictionary keys
    grades (int): student's grades for corresponding courses on a 0-4 scale
                  - dictionary values
    gpa (float): student's grade point average - property method
    """

    def __init__(self, name, cid, email=''):
        self.courses = {}
        self.grades = 0
        super().__init__(name, cid, email)

    def add_course(self, course):
        """
        Add a course to a student's schedule

        Parameter:
        course (string): course (key) to be added to the course dictionary,
                         with an initial grade of 0 (value). If the student is
                         already enrolled in the course, a NameError is raised.
        Returns: updated Student object
        """
        if course in self.courses:
            raise NameError('This student is already enrolled in that course')
        else:
            self.courses[course] = 0
        return self

    def update_grade(self, course, grade):
        """
        Add a corresponding grade to a student's course

        Parameter:
        course (string): course (key) in the 'courses' dictionary that needs an
        updated grade (value)
        grade (integer): grade of corresponding course on a scale of 0-4
        Returns: updated Student object
        """
        if course not in self.courses:
            raise NameError('This student is not enrolled in that course')
        else:
            self.courses[course] = grade
        return self

    @property
    def gpa(self):
        """
        Calculates a Student's grade point average.

        If a student is not enrolled in any courses, return 0. Otherwise,
        return a student's gpa (float) which is the sum of the student's grades
        divided by the number of registered courses
        """
        try:
            return sum(self.courses.values()) / len(self.courses)
        except ZeroDivisionError:
            return 0

<mask token>


class Person(object):
    <mask token>
    <mask token>

    def __str__(self):
        result = 'NAME: ' + self.name + '\n' + 'ID: ' + str(self.cid
            ) + '\n' + 'EMAIL: ' + self.email
        return result


class Student(Person):
    """
    Represent a Student in a college environment

    Arguments:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address - defaults to the empty string

    Attributes:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address
    courses (string): student's current and previous courses - dictionary keys
    grades (int): student's grades for corresponding courses on a 0-4 scale
                  - dictionary values
    gpa (float): student's grade point average - property method
    """

    def __init__(self, name, cid, email=''):
        self.courses = {}
        self.grades = 0
        super().__init__(name, cid, email)

    def add_course(self, course):
        """
        Add a course to a student's schedule

        Parameter:
        course (string): course (key) to be added to the course dictionary,
                         with an initial grade of 0 (value). If the student is
                         already enrolled in the course, a NameError is raised.
        Returns: updated Student object
        """
        if course in self.courses:
            raise NameError('This student is already enrolled in that course')
        else:
            self.courses[course] = 0
        return self

    def update_grade(self, course, grade):
        """
        Add a corresponding grade to a student's course

        Parameter:
        course (string): course (key) in the 'courses' dictionary that needs an
        updated grade (value)
        grade (integer): grade of corresponding course on a scale of 0-4
        Returns: updated Student object
        """
        if course not in self.courses:
            raise NameError('This student is not enrolled in that course')
        else:
            self.courses[course] = grade
        return self

    @property
    def gpa(self):
        """
        Calculates a Student's grade point average.

        If a student is not enrolled in any courses, return 0. Otherwise,
        return a student's gpa (float) which is the sum of the student's grades
        divided by the number of registered courses
        """
        try:
            return sum(self.courses.values()) / len(self.courses)
        except ZeroDivisionError:
            return 0

<mask token>


class Person(object):
    <mask token>

    def __init__(self, name, cid, email=''):
        self.name = name
        self.cid = cid
        self.email = email

    def __str__(self):
        result = 'NAME: ' + self.name + '\n' + 'ID: ' + str(self.cid
            ) + '\n' + 'EMAIL: ' + self.email
        return result


class Student(Person):
    """
    Represent a Student in a college environment

    Arguments:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address - defaults to the empty string

    Attributes:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address
    courses (string): student's current and previous courses - dictionary keys
    grades (int): student's grades for corresponding courses on a 0-4 scale
                  - dictionary values
    gpa (float): student's grade point average - property method
    """

    def __init__(self, name, cid, email=''):
        self.courses = {}
        self.grades = 0
        super().__init__(name, cid, email)

    def add_course(self, course):
        """
        Add a course to a student's schedule

        Parameter:
        course (string): course (key) to be added to the course dictionary,
                         with an initial grade of 0 (value). If the student is
                         already enrolled in the course, a NameError is raised.
        Returns: updated Student object
        """
        if course in self.courses:
            raise NameError('This student is already enrolled in that course')
        else:
            self.courses[course] = 0
        return self

    def update_grade(self, course, grade):
        """
        Add a corresponding grade to a student's course

        Parameter:
        course (string): course (key) in the 'courses' dictionary that needs an
        updated grade (value)
        grade (integer): grade of corresponding course on a scale of 0-4
        Returns: updated Student object
        """
        if course not in self.courses:
            raise NameError('This student is not enrolled in that course')
        else:
            self.courses[course] = grade
        return self

    @property
    def gpa(self):
        """
        Calculates a Student's grade point average.

        If a student is not enrolled in any courses, return 0. Otherwise,
        return a student's gpa (float) which is the sum of the student's grades
        divided by the number of registered courses
        """
        try:
            return sum(self.courses.values()) / len(self.courses)
        except ZeroDivisionError:
            return 0

<mask token>


class Person(object):
    """
    Represent a person affiliated with the college: student, faculty or staff

    Arguments:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address - defaults to the empty string

    Attributes:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address
    """

    def __init__(self, name, cid, email=''):
        self.name = name
        self.cid = cid
        self.email = email

    def __str__(self):
        result = 'NAME: ' + self.name + '\n' + 'ID: ' + str(self.cid
            ) + '\n' + 'EMAIL: ' + self.email
        return result


class Student(Person):
    """
    Represent a Student in a college environment

    Arguments:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address - defaults to the empty string

    Attributes:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address
    courses (string): student's current and previous courses - dictionary keys
    grades (int): student's grades for corresponding courses on a 0-4 scale
                  - dictionary values
    gpa (float): student's grade point average - property method
    """

    def __init__(self, name, cid, email=''):
        self.courses = {}
        self.grades = 0
        super().__init__(name, cid, email)

    def add_course(self, course):
        """
        Add a course to a student's schedule

        Parameter:
        course (string): course (key) to be added to the course dictionary,
                         with an initial grade of 0 (value). If the student is
                         already enrolled in the course, a NameError is raised.
        Returns: updated Student object
        """
        if course in self.courses:
            raise NameError('This student is already enrolled in that course')
        else:
            self.courses[course] = 0
        return self

    def update_grade(self, course, grade):
        """
        Add a corresponding grade to a student's course

        Parameter:
        course (string): course (key) in the 'courses' dictionary that needs an
        updated grade (value)
        grade (integer): grade of corresponding course on a scale of 0-4
        Returns: updated Student object
        """
        if course not in self.courses:
            raise NameError('This student is not enrolled in that course')
        else:
            self.courses[course] = grade
        return self

    @property
    def gpa(self):
        """
        Calculates a Student's grade point average.

        If a student is not enrolled in any courses, return 0. Otherwise,
        return a student's gpa (float) which is the sum of the student's grades
        divided by the number of registered courses
        """
        try:
            return sum(self.courses.values()) / len(self.courses)
        except ZeroDivisionError:
            return 0

# -----------------------------------------------------------------------------
# Name:        college
# Purpose:     class definitions for a college environment
#
 # Author:     Raymond Cabrera
#
# Date:  2/21/16
# -----------------------------------------------------------------------------
"""
Module to describe a college setting.

"""
class Person(object):

    """
    Represent a person affiliated with the college: student, faculty or staff

    Arguments:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address - defaults to the empty string

    Attributes:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address
    """

    def __init__(self, name, cid, email = ''):
        self.name = name
        self.cid = cid
        self.email = email

    def __str__(self):
        result = ('NAME: ' + self.name + '\n' +
                'ID: ' + str(self.cid) + '\n' +
                'EMAIL: '  + self.email)
        return result


class Student(Person):
    """
    Represent a Student in a college environment

    Arguments:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address - defaults to the empty string

    Attributes:
    name (string): person's name
    cid (int): college id number - 8 digits
    email (string): email address
    courses (string): student's current and previous courses - dictionary keys
    grades (int): student's grades for corresponding courses on a 0-4 scale
                  - dictionary values
    gpa (float): student's grade point average - property method
    """

    def __init__(self, name, cid, email=''):
        self.courses = {}
        self.grades = 0
        super().__init__(name, cid, email)

    def add_course(self, course):
        """
        Add a course to a student's schedule

        Parameter:
        course (string): course (key) to be added to the course dictionary,
                         with an initial grade of 0 (value). If the student is
                         already enrolled in the course, a NameError is raised.
        Returns: updated Student object
        """
        if course in self.courses:
            raise NameError('This student is already enrolled in that course')
        else:
            self.courses[course] = 0

        return self

    def update_grade(self, course, grade):
        """
        Add a corresponding grade to a student's course

        Parameter:
        course (string): course (key) in the 'courses' dictionary that needs an
        updated grade (value)
        grade (integer): grade of corresponding course on a scale of 0-4
        Returns: updated Student object
        """
        if course not in self.courses:
            raise NameError('This student is not enrolled in that course')
        else:
            self.courses[course] = grade

        return self



    @property
    def gpa(self):
        """
        Calculates a Student's grade point average.

        If a student is not enrolled in any courses, return 0. Otherwise,
        return a student's gpa (float) which is the sum of the student's grades
        divided by the number of registered courses
        """
        try:
            return sum(self.courses.values()) / len(self.courses)
        except ZeroDivisionError:
            return 0
