OneCompiler

urkurk c6

109
 class Attendance:
#Constructor: takes a list of student names (strings).    
    def __init__(self, student_names):
        self.list = set(student_names)
        self.student_names = set()
        
#marks a student as present. Returns True if successful, False if the student does not exist. 
    def mark_present(self, student):
        if student in self.list:
            self.student_names.add(student)
            return True
        return False
#returns a list of students who are marked present.        
    def get_present_students(self):
        return sorted(self.student_names)
#returns a list of students who are not marked present.        
    def get_absent_students(self):
        return sorted(self.list - self.student_names)
#clears the attendance record.        
    def reset_attendance(self):
        self.student_names.clear()