Calculator App
This is a Calculator package that contains 5 modules (calculator.py, tests.py, setup.py,init.py for calulator.py and init.py for tests.py), Dockerfile, LICENSE, .gitignore and .dockerignore. The written calculator.py module acts as a normal calculator by adding, subtracting, multiplying, dividing and taking the nth root of a number. This module also contains methods of reseting memory, allocating memory from what you want to start, setting and getting a memory value (not to be confused with memory allocation to stack and heap). Please refer to Installation and Requirements before looking into the examples.
To run the package you'll have to first download and install it by running this command on colab, jupyter notebook, terminal:
> pip install git+git://github.com/aurimas13/calculator
When it is downloaded navigate to python shell. When there import the module by:
>>> from calculator.calculator import Calculator
or
>>> from calculator.calculator import *
Python 3.8.5 is required to run package's modules. Imports of pytest, math and typing are also needed.
After installation is done then you'll have to instantiate a Calculator class and play with it by running methods:
>>> calc = Calculator()
>>> calc.add(10)
10
>>> calc.subtract(5)
5
>>> calc.multiply(50)
250
>>> calc.divide(2)
125.0
calc.divide(4.5)
27.7778
>>> calc.multiply(4.5)
125.0001
>>> calc.subtract(25)
100.0001
>>> calc.subtract(2)
98.0001
>>> calc.add(2)
100.0001
>>> calc.root(2)
10.000004999998751
>>> calc.reset()
0
>>> calc.set_memory(6)
>>> calc.get_memory()
6
First navigate to where calculator.py or tests.py is held.
For DocTest run this command in terminal:
> python -m doctest -v calculator.py
To check source files for error run:
> pyflakes calculator.py
> pyflakes tests.py
For typing run:
> mypy calculator.py
> mypy tests.py
Setup up of dockerfile.
To build docker image on terminal run:
> docker build -t calculatorapp .
To enter python prompt through docker:
> docker run -it calculatorapp python
The commands to run in it are shown in (Usage)