Skip to main content

A lightweight Python library for attendance calculations

Project description

attendancex

A lightweight, dependency-free Python library for attendance calculations and planning.

PyPI version Python License: MIT


What is attendancex?

attendancex is a pure Python library that handles attendance logic — so developers don't have to write it themselves.

It works as a calculation engine that can be plugged into any project — a college app, a chatbot, a web dashboard, or an academic management system.


Installation

pip install attendancex

Usage

import attendancex

By default, all functions use 75% as the minimum required attendance. To use a different percentage, pass required_percent to any function:

# Default — 75% minimum
attendancex.safe_bunks(attended=49, total=60)

# Custom — 80% minimum
attendancex.safe_bunks(attended=49, total=60, required_percent=80)

Examples

# Current attendance percentage
# attended=45 classes out of total=60 classes held
attendancex.calculate_percentage(attended=45, total=60)
# → 75.0

# How many classes can I skip and stay above 75%?
# attended=49 out of total=60
attendancex.safe_bunks(attended=49, total=60)
# → 4

# My attendance is low — how many consecutive classes must I attend to reach 75%?
# attended=30 out of total=60 — currently at 50%
attendancex.classes_needed(attended=30, total=60)
# → 60

# Can I still pass by end of semester?
# attended=45, total=60 held, remaining=20 classes left
attendancex.will_pass(attended=45, total=60, remaining=20)
# → True

# If I attend all upcoming classes, what will my percentage be?
# attended=45, total=60, extra_classes=10 upcoming
attendancex.projected_attendance(attended=45, total=60, extra_classes=10)
# → 78.57

# Minimum classes I must attend from remaining to pass?
# attended=45, total=60 held, remaining=20 classes left
attendancex.minimum_to_pass(attended=45, total=60, remaining=20)
# → 15

# How many classes can I skip in a row right now?
# attended=49 out of total=60
attendancex.bunk_streak(attended=49, total=60)
# → 5

# Full attendance report in one call
attendancex.attendance_summary(attended=45, total=60, remaining=20)
# → {
#     'percentage': 75.0,            # current attendance %
#     'status': 'warning',           # safe / warning / critical
#     'safe_bunks': 0,               # classes that can be skipped
#     'classes_needed': 0,           # classes needed to recover
#     'will_pass': True,             # can still pass this semester?
#     'projected_attendance': 81.25, # % if all remaining classes attended
#     'minimum_to_pass': 15,         # minimum to attend from remaining
#     'bunk_streak': 0               # max consecutive bunks right now
#   }

All Functions

Function Returns Description
calculate_percentage(attended, total) float Current attendance percentage
safe_bunks(attended, total) int Classes that can be safely skipped
classes_needed(attended, total) int Classes to attend to reach required %
will_pass(attended, total, remaining) bool Whether passing is still achievable
projected_attendance(attended, total, extra_classes) float % if all future classes are attended
minimum_to_pass(attended, total, remaining) int Minimum classes to attend from remaining
bunk_streak(attended, total) int Max classes that can be skipped in a row
attendance_summary(attended, total, remaining) dict Complete attendance report

Error Handling

try:
    attendancex.calculate_percentage(attended=45, total=0)
except ValueError as e:
    print(e)
# → 'total' must be greater than zero

try:
    attendancex.calculate_percentage(attended=70, total=60)
except ValueError as e:
    print(e)
# → 'attended' cannot be greater than 'total'

License

MIT — free to use, modify, and distribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

attendancex-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

attendancex-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file attendancex-0.1.0.tar.gz.

File metadata

  • Download URL: attendancex-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for attendancex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d1b274975dddd42e4f2e482b8ac6756df360915bb69f64ae972c28b0756b0054
MD5 1c73b362ef12833d511dbff781d34d12
BLAKE2b-256 b6b82cce7259fffccffae6745345e07fc8b8c6a86652dfe85092d4963a3c3b9d

See more details on using hashes here.

File details

Details for the file attendancex-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: attendancex-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for attendancex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f49d2a331b3e59f36c2190611b032615092c666608a0f458274a4fa5b84cbe4d
MD5 b455981533529797e3f062523010abf1
BLAKE2b-256 53d733ee9fca69ae681d487725f31e17c2ee1a27fade7a7de541a001c225aebe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page