I have two classes Course and Student. Course has a function that grades a student and gives a score. I'm trying to build a function in Student that takes that grade and shows the total score for a particular student.
class courseClass(object):
def grade(self, student, grade):
self.grade = grade
if self.grade == 1:
print("Student passed mandatory assignment")
elif self.grade == 0:
print("Student failed mandatory assignment")
elif self.grade != 0 or 1:
raise Exception("score is out of pattern range")
course_instance = courseClass()
course_instance.grade(student1, 1)
class Student(object):
def grade_status(self, student):
return [i.grade for i in self.grade]
student1 = Student("Bob Bobson", 20, 58008)
x = Student.grade_status(student1)
print(x)
AttributeError: 'Student' object has no attribute 'grade'
I think it needs to something like this instead:
def grade_status(self, grade):
self.grade =
But I don't know how to make it equal to the grade that's being given at the grade function (and will it know which student it is assigned to?)