diff --git a/Makefile b/Makefile index f4db715..2d3cb55 100644 --- a/Makefile +++ b/Makefile @@ -3,5 +3,8 @@ install: pip install --upgrade pip pip install -r requirements.txt +run: + python src/main.py + test: python -m pytest -v diff --git a/main.py b/main.py deleted file mode 100644 index d4a8ddd..0000000 --- a/main.py +++ /dev/null @@ -1,2 +0,0 @@ -if __name__ == "__main__": - print("This is a test") diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..2014185 --- /dev/null +++ b/src/main.py @@ -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)) diff --git a/src/modules/__pycache__/math.cpython-313.pyc b/src/modules/__pycache__/math.cpython-313.pyc new file mode 100644 index 0000000..eb1aa60 Binary files /dev/null and b/src/modules/__pycache__/math.cpython-313.pyc differ diff --git a/src/modules/__pycache__/strings.cpython-313.pyc b/src/modules/__pycache__/strings.cpython-313.pyc new file mode 100644 index 0000000..1cfcf5c Binary files /dev/null and b/src/modules/__pycache__/strings.cpython-313.pyc differ diff --git a/src/modules/math.py b/src/modules/math.py new file mode 100644 index 0000000..9b83bbf --- /dev/null +++ b/src/modules/math.py @@ -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 diff --git a/src/modules/strings.py b/src/modules/strings.py new file mode 100644 index 0000000..9463f2a --- /dev/null +++ b/src/modules/strings.py @@ -0,0 +1,3 @@ +def t_strings(): + my_template = "This is a value: {test}" + print(my_template.format(test="another"))