Python Numpy Mini Projects: Simple Attendance System

               Attendance system is a common system which marks the student’s entry. when they are getting in to the school or college, it puts the attendance.

Present means 1 and absent means 0.

Let us implement this program.

Implementation:

  • This program creates a student array. Next, attendance entry matrix is created.  
  • Attendance analysis is done as follows..
  • First, attendance percentage for each student is created according to the data.
  • Next, below 75% attendance students are displayed separately.

Code:

import numpy as np1

# Student names

students = np1.array(["Ajay", "Bob", "Charan", "Dia", "Marya", "Henry"])

# Attendance for 6 days (1 = Present, 0 = Absent)

attendance = np1.array([

    [1, 1, 0, 1, 1, 1], 

    [1, 0, 1, 1, 0, 0], 

    [1, 1, 1, 1, 1, 1], 

    [0, 1, 0, 1, 1, 0], 

    [1, 1, 1, 0, 1, 1],

    [1, 1, 1, 1, 0, 1] 

])

print("Attendance Matrix of the students:")

print(attendance)

# Total days present

total_present = np1.sum(attendance, axis=1)

print("\nStudent Attendance Report")

for i in range(len(students)):

    percentage = (total_present[i] / attendance.shape[1]) * 100

    print(f"{students[i]} : {total_present[i]} days present ({percentage:.1f}%)")

# Class statistics

print("\nClass Statistics")

print("Average Attendance:", np1.mean(attendance) * 100, "%")

# Students with attendance below 75%

print("\nStudents Below 75% Attendance:")

for i in range(len(students)):

    percentage = (total_present[i] / attendance.shape[1]) * 100

    if percentage < 75:

        print(students[i])

Output:

Attendance Matrix of the students:

[[1 1 0 1 1 1]

 [1 0 1 1 0 0]

 [1 1 1 1 1 1]

 [0 1 0 1 1 0]

 [1 1 1 0 1 1]

 [1 1 1 1 0 1]]

Student Attendance Report

Ajay : 5 days present (83.3%)

Bob : 3 days present (50.0%)

Charan : 6 days present (100.0%)

Dia : 3 days present (50.0%)

Marya : 5 days present (83.3%)

Henry : 5 days present (83.3%)

Class Statistics

Average Attendance: 75.0 %

Students Below 75% Attendance:

Bob

Dia

Hope, this implementation is useful to you. Keep Coding!!!

Comments

Popular posts from this blog

How to create a XML DTD for displaying student details

Employee record management in C

Datatypes and Variables in java script