Skip to main content

A beginner-friendly package for advanced mathematical calculations including finance, number theory, strings, matrices, statistics, and geometry.

Project description

Advanced Math Utilities (adpkg)

Welcome! 👋 This package gives you a bunch of handy tools for math, finance, and geometry in Python. You don’t need to be a math expert—just import and use!

It includes modules for:

  • Finance: Calculate compound interest easily
  • Number Theory: Check primes, factorials, permutations, combinations
  • Strings: Reverse words or phrases
  • Matrices: Add, multiply, transpose, and find determinants
  • Statistics: Mean, median, mode
  • Geometry: Triangle area with Heron’s formula

PyPI version Python License Downloads Last Commit Contributors


📑 Table of Contents


📦 Installation

Install from PyPI (make sure you have Python installed):

pip install adpkg

Check if it worked:

python -m pip show adpkg

🚀 Quick Start

Here are simple examples to get you started. More detailed examples are below.

from adpkg import finance, adcustom, triangle

# Calculate compound interest
print(finance.interest(1000, "1y", 12, 5))

# Factorial
print(adcustom.factorial(5))

# Reverse a string
print(adcustom.string_reverse("hello"))

# Area of a triangle
print(triangle.areaoftriangle(3, 4, 5))

💰 Finance Module

interest(prime_amount, time_duration_str, n, rate)

  • Calculates compound interest based on years/months.
  • Duration formats: "2y", "6m", or "1y6m".
from adpkg import finance
print(finance.interest(1000, "1y", 12, 5))   # 51.161
print(finance.interest(2000, "5y", 4, 7))   # 816.622

# Edge case: invalid input
print(finance.interest(1000, "abc", 12, 5))  # None

🔢 AdCustom Module

Number Theory

check_prime(n) → 1 if prime, 0 if not, None if invalid.

print(adcustom.check_prime(17))  # 1
print(adcustom.check_prime(10))  # 0

factorial(n)

print(adcustom.factorial(5))   # 120
print(adcustom.factorial(-2))  # None

permutation(n, r)

print(adcustom.permutation(5, 2))  # 20

combination(n, r)

print(adcustom.combination(5, 2))  # 10

Strings

string_reverse(s)

print(adcustom.string_reverse("hello"))  # "olleh"

Matrices

matrix_addition(a, b)

print(adcustom.matrix_addition([[1,2],[3,4]], [[5,6],[7,8]]))
# [[6,8],[10,12]]

matrix_multiplication(a, b)

print(adcustom.matrix_multiplication([[1,2],[3,4]], [[5,6],[7,8]]))
# [[19,22],[43,50]]

matrix_transpose(a)

print(adcustom.matrix_transpose([[1,2,3],[4,5,6]]))
# [[1,4],[2,5],[3,6]]

determinant_value(a)

print(adcustom.determinant_value([[1,2],[3,4]]))  # -2

Statistics

mean(data)

print(adcustom.mean([1,2,3,4,5]))  # 3.0

median(data)

print(adcustom.median([1,3,2,5,4]))  # 3

mode(data)

print(adcustom.mode([1,2,2,3,4,4,4,5]))  # ([4], 3)

🔺 Triangle Module

areaoftriangle(a, b, c, unit='')

  • Uses Heron’s formula.
print(triangle.areaoftriangle(3, 4, 5))           # 6.0
print(triangle.areaoftriangle(3, 4, 5, "sq cm")) # "6.0 sq cm"

🧪 Running Tests

We included some test files (test1.pytest5.py).

Run one test:

python test1.py

Run all tests at once:

python -m unittest discover -s . -p "test*.py"

🛠️ Contributing

Want to help? Awesome! Here’s how:

  1. Fork this repo → Make your own copy on GitHub.
  2. Create a branch → Work on your changes in a separate branch.
  3. Add your code and tests → Make sure it works!
  4. Open a Pull Request → Propose your changes.

🗺️ Roadmap

  • ✅ Current: Finance, number theory, strings, matrices, stats, triangles
  • 🔜 Next: Probability, calculus, polynomials, advanced linear algebra
  • 📊 Future: Machine learning helpers, symbolic algebra, optimization

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.


📬 Contact

Author
Email
GitHub
PyPI
LinkedIn
Twitter
Instagram

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

adpkg-0.1.3.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

adpkg-0.1.3-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file adpkg-0.1.3.tar.gz.

File metadata

  • Download URL: adpkg-0.1.3.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for adpkg-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4f6b6b6e18a31a033ac62c04da96aa4eca71a17d66e743295adec2e70a7f507f
MD5 3eabf7053d2c3b7cf9a99fe8b4edcb74
BLAKE2b-256 d7523a53ed06144654795413b97c1ef50bf20836f32d4bdb48abf02888ab03ac

See more details on using hashes here.

File details

Details for the file adpkg-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: adpkg-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for adpkg-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2c092d8abcb309d762364ebeead9c80be5d6d3be6634ec22e0ae1adda4bf0c9c
MD5 bb36083fd4d5761e6bcf64dac3780a8c
BLAKE2b-256 fcae3c5d30bd2faa0553a18bb7c1ac0d5ed5454b9d663429d34635421cfea123

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