class student_name:
    def __init__(self,student):
        self.student = student
    def student_name(self):
        print('Student Name: ', self.student)

class Majors:
    def __init__(self,name1,name2):
        self.name1 = name1
        self.name2 = name2
    def major(self):
    def major2(self):
        print('Majors: ',self.name1, self.name2)

class School:
    def __init__(self,school): = school
    def school_name(self):
        print('School Name: ',
class Student_Track:
    def __init__(self, School, student_name, Majors):
        self.School = School
        self.student_name = student_name
        self.Majors = Majors
    def track (self):
        print( 'School Name: ', School,
               'Student Name: ', student_name,
               'Majors: ', Majors)

ob1 = student_name('bob')
ob2 = Majors('l','l')
ob3 = School('o')
ob4 = Student_Track(ob3.school_name,ob1,ob2)

Design a class for a Student/Major tracking system. You may use stubs for the member methods. Include a Class Diagram.I get:

"School Name: <class 'main.School'> Student Name: <class 'main.student_name'> Majors: <class 'main.Majors'>"

instead of:

Student Name: bob
Majors: l l
School Name: o

in one line

The problem you are having is three-fold. First, you are using the same names (student_name, School, and Majors) for both classes, and for the parameters to the to Student_Track.__init__(). Second, you are using the names of the classes in your print statement, rather than names of the instance variables (which always bgine with self., remember). Thirs, you are attempting to print the objects directly, without defining a __str__() method for them.

While I have not tested this, I think tha the following will fix the problem:

class Student_Name:
    def __init__(self, student):
        self.student = student
    def __str__(self):
        return 'Student Name: {name}'.format(name=self.student)

class Majors:
    def __init__(self, major, minor):
        self.major = major
        self.minor = minor
    def __str__(self):
        return 'Majors: {0}, {1}'.format(self.major, self.minor)

class School:
    def __init__(self,school): = school
    def __str__(self):
        return 'School Name: {0}'.format(
class Student_Track:
    def __init__(self, school, student,  majors): = school
        self.student = student
        self.majors = majors
    def __str__(self):
        return '{school},\n{student}\n{majors}\n'.format(

ob1 = Student_Name('bob')
ob2 = Majors('l','l')
ob3 = School('o')
ob4 = Student_Track(ob3,ob1,ob2)

Edited 3 Years Ago by Schol-R-LEA

Thanks. Looks like I need more practice with classes.

This question has already been answered. Start a new discussion instead.