└── SmartAttendanceSystem.py /SmartAttendanceSystem.py: -------------------------------------------------------------------------------- 1 | def mark_attendance(student_id): 2 | with open('attendance.txt', 'a') as file: 3 | file.write(f'{student_id}\n') 4 | 5 | def view_attendance(): 6 | with open('attendance.txt', 'r') as file: 7 | attendance_list = file.readlines() 8 | return attendance_list 9 | 10 | def main(): 11 | while True: 12 | print("Welcome to the Student Attendance System") 13 | print("1. Mark Attendance") 14 | print("2. View Attendance") 15 | print("3. Quit") 16 | 17 | choice = input("Enter your choice: ") 18 | 19 | if choice == '1': 20 | student_id = input("Enter student ID: ") 21 | mark_attendance(student_id) 22 | 23 | elif choice == '2': 24 | attendance_list = view_attendance() 25 | print("\nAttendance List") 26 | for record in attendance_list: 27 | print(record.strip()) 28 | 29 | elif choice == '3': 30 | break 31 | 32 | else: 33 | print("Invalid choice") 34 | 35 | if __name__ == '__main__': 36 | main() 37 | 38 | --------------------------------------------------------------------------------