Categories We Write About

Build a classroom attendance tracker

Here’s a simple classroom attendance tracker using Python with a CSV file to store attendance records. This implementation includes basic features:

  • Register students

  • Mark attendance for each day

  • View attendance records

python
import csv import os from datetime import datetime FILENAME = "attendance.csv" def init_file(): if not os.path.exists(FILENAME): with open(FILENAME, mode="w", newline="") as file: writer = csv.writer(file) writer.writerow(["Date", "Student Name", "Status"]) def register_student(name): print(f"Student '{name}' registered (for attendance marking).") def mark_attendance(name, status="Present"): date = datetime.now().strftime("%Y-%m-%d") with open(FILENAME, mode="a", newline="") as file: writer = csv.writer(file) writer.writerow([date, name, status]) print(f"Attendance marked: {name} - {status} on {date}") def view_attendance(): if not os.path.exists(FILENAME): print("No attendance records found.") return with open(FILENAME, mode="r") as file: reader = csv.reader(file) for row in reader: print(", ".join(row)) def main(): init_file() while True: print("n--- Classroom Attendance Tracker ---") print("1. Register Student") print("2. Mark Attendance") print("3. View Attendance") print("4. Exit") choice = input("Select an option: ") if choice == "1": name = input("Enter student name: ") register_student(name) elif choice == "2": name = input("Enter student name: ") status = input("Enter status (Present/Absent): ").capitalize() if status not in ["Present", "Absent"]: status = "Present" mark_attendance(name, status) elif choice == "3": view_attendance() elif choice == "4": print("Exiting program.") break else: print("Invalid option. Please try again.") if __name__ == "__main__": main()

Features you can add:

  • GUI (with Tkinter or PyQt)

  • Database backend (SQLite or Firebase)

  • Exporting reports (PDF, Excel)

  • Login system for teachers

Let me know if you want a version with a web interface or integrated with Google Sheets.

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories We Write About