[!CAUTION]
UNMAINTAINED REPOSITORY
This project is no longer actively developed or maintained. It is kept public for historical purposes and reference.
Issues and Pull Requests will not be reviewed or merged. β
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:
Install from PyPI (make sure you have Python installed):
pip install adpkg
Check if it worked:
python -m pip show adpkg
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))
interest(prime_amount, time_duration_str, n, rate)"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
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
string_reverse(s)print(adcustom.string_reverse("hello")) # "olleh"
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
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)
areaoftriangle(a, b, c, unit='')print(triangle.areaoftriangle(3, 4, 5)) # 6.0
print(triangle.areaoftriangle(3, 4, 5, "sq cm")) # "6.0 sq cm"
We included some test files (test1.py β test5.py).
Run one test:
python test1.py
Run all tests at once:
python -m unittest discover -s . -p "test*.py"
Want to help? Awesome! Hereβs how:
This project is licensed under the MIT License - see the LICENSE file for details.