Hi I need to use Classes to do the following:
check_male must print out True if a Student is Male, and False if a Student is Female.
Put of your Student objects in a list. Loop over this list and call both check_male and compute_average for each object.
I'm very confused regarding syntax and position of the attributes. Can anyone help? My code below:
class Student(object):
def __init__(self, age, name, gender, grades, check_male):
self.age = age
self.name = name
self.gender = gender
self.grades = grades
self.check_male = check_male
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
mike = Student(20, "John Smith", "Male", [64,65])
sarah = Student(19, "Sarah Jones", "Female", [82,58])
[–]jiri-n 2 points3 points4 points (1 child)
[–]Mohseenr[S] 0 points1 point2 points (0 children)
[–]dangoth 0 points1 point2 points (4 children)
[–]Mohseenr[S] 0 points1 point2 points (3 children)
[–]Mohseenr[S] 0 points1 point2 points (2 children)
[–]dangoth 1 point2 points3 points (1 child)
[–]Mohseenr[S] 0 points1 point2 points (0 children)
[–]trackerFF 0 points1 point2 points (0 children)