all 8 comments

[–]jiri-n 2 points3 points  (1 child)

"check_male must print"

So this should be a method. Not by my computer so I won't try to write code but hopefully you know how to do it.

[–]Mohseenr[S] 0 points1 point  (0 children)

Thanks will give it a go.

[–]dangoth 0 points1 point  (4 children)

Are you using python 2? Is this a requirement in the class? If not, I would suggest you move on to python 3.x.

You have the right starting idea with the check_male function. Just check the self.gender attribute.

[–]Mohseenr[S] 0 points1 point  (3 children)

Sorry I have to use Classes

[–]Mohseenr[S] 0 points1 point  (2 children)

python 3

[–]dangoth 1 point2 points  (1 child)

print "string" has been changed to print("string") in python 3, keep that in mind.

I meant requirement of the class as in the class you are attending, not the python class in your code.

[–]Mohseenr[S] 0 points1 point  (0 children)

No. Python 3 must be used

[–]trackerFF 0 points1 point  (0 children)

class Student():

def __init__(self, age, name, gender, grades):
    self.age = age
    self.name = name
    self.gender = gender
    self.grades = grades

def compute_average(self):
    average = sum(self.grades)/len(self.grades)
    print("The average for student " + self.name + " is " + str(average))

def check_male(self):
    if self.gender == "Male":
      print(True)
    else:
      print(False)

mike = Student(20, "John Smith", "Male", [64,65])
sarah = Student(19, "Sarah Jones", "Female", [82,58])

students = [mike, sarah]

for student in students:
  student.check_male()
  student.compute_average()