feat: main structure + basic math testing
This commit is contained in:
3
Makefile
3
Makefile
@@ -3,5 +3,8 @@ install:
|
|||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
run:
|
||||||
|
python src/main.py
|
||||||
|
|
||||||
test:
|
test:
|
||||||
python -m pytest -v
|
python -m pytest -v
|
||||||
|
|||||||
8
src/main.py
Normal file
8
src/main.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from modules.math import t_compound_interest, t_compound_interest_algorigthm, t_exponent
|
||||||
|
from modules.strings import t_strings
|
||||||
|
|
||||||
|
if __name__=="__main__":
|
||||||
|
t_strings()
|
||||||
|
t_exponent(2,8)
|
||||||
|
print(t_compound_interest(100, 20 / 100, 2, 12))
|
||||||
|
print(t_compound_interest_algorigthm(100, 20 / 100, 2, 12))
|
||||||
BIN
src/modules/__pycache__/math.cpython-313.pyc
Normal file
BIN
src/modules/__pycache__/math.cpython-313.pyc
Normal file
Binary file not shown.
BIN
src/modules/__pycache__/strings.cpython-313.pyc
Normal file
BIN
src/modules/__pycache__/strings.cpython-313.pyc
Normal file
Binary file not shown.
26
src/modules/math.py
Normal file
26
src/modules/math.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from cmath import log as complex_log # used for complex numbers
|
||||||
|
from math import log
|
||||||
|
|
||||||
|
|
||||||
|
def t_summ():
|
||||||
|
# Equivalent to summatory of 2*i from i=1 to i=5
|
||||||
|
return sum(2*i for i in range(1,6))
|
||||||
|
|
||||||
|
def t_exponent(base, exponent):
|
||||||
|
return base**exponent
|
||||||
|
|
||||||
|
def t_logarithm(n, base):
|
||||||
|
return log(n, base)
|
||||||
|
|
||||||
|
def t_complex_logarithm(n, base):
|
||||||
|
return complex_log(n, base)
|
||||||
|
|
||||||
|
def t_compound_interest(input, interest, span, periods):
|
||||||
|
return input * ((1 + (interest / periods))**(periods * span))
|
||||||
|
|
||||||
|
def t_compound_interest_algorigthm(input, interest, span, periods):
|
||||||
|
result = input
|
||||||
|
for _ in range(0, span):
|
||||||
|
for _ in range(0, periods):
|
||||||
|
result += result * (interest / periods)
|
||||||
|
return result
|
||||||
3
src/modules/strings.py
Normal file
3
src/modules/strings.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
def t_strings():
|
||||||
|
my_template = "This is a value: {test}"
|
||||||
|
print(my_template.format(test="another"))
|
||||||
Reference in New Issue
Block a user