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


📦 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.4.tar.gz (13.0 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.4-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: adpkg-0.1.4.tar.gz
  • Upload date:
  • Size: 13.0 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.4.tar.gz
Algorithm Hash digest
SHA256 6a2a098baeb2b7cf55b263d90109b19a50de9eeda17ef7e26e8fd4c5e4fef41c
MD5 c5047538f7edba6d09e4f83785463451
BLAKE2b-256 0d105d54772fd6a1833664d77f16100cce8d10040728e2d48387115f7f4a4c99

See more details on using hashes here.

File details

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

File metadata

  • Download URL: adpkg-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 11.4 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 321492a21c11552622af709c08feb03038c5e78021e9b454a386f8116590a614
MD5 b3d1a5e800a4500e22dc0a3dfa5ba37b
BLAKE2b-256 7084e36ec8931a576c562d11305b1be22f9341248c8700fcd3c3aed13f611a32

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