Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mascrypt0/calculator
Simple calculator build in python
https://github.com/mascrypt0/calculator
calculator-python python
Last synced: about 2 months ago
JSON representation
Simple calculator build in python
- Host: GitHub
- URL: https://github.com/mascrypt0/calculator
- Owner: mascrypt0
- License: mit
- Created: 2024-02-25T17:21:12.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-25T17:34:37.000Z (11 months ago)
- Last Synced: 2024-02-25T18:39:06.304Z (11 months ago)
- Topics: calculator-python, python
- Language: Python
- Homepage: https://github.com/mascrypt0/calculator
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Scientific Python Calculator
Scientific Python Calculator is a library for doing mathematics computation. It works similar to a calculator.
:raised_hands: This is my first python package. It will be improved over time. Feel free to contribute to this beautiful work of art.
## Installation
:warning: only tested with python 3.**Installation via PYPI**
```sh
$ pip install scipy-calculator
```
**Installation via Github**
this is for the stable released version
```sh
$ pip install git+https://github.com/mascrypt0/calculator
```scipy_calculator uses multipledispatch dependency and pytest for automated test
## Usage
The calculator can be used for basic mathematical computation. The calculator has a memory that caches the last result until it is reset. The cached result is used in the next computation if not reset.The `reset` is used to clear the cache
Examples will be shown below
## Sample Code
```python
from calculator import Calculatormy_cal = Calculator()
```
### Addition
```python
>>> my_cal.add(10)
10
```
#### Subtraction
`subtract`
```python
>>> my_cal.subtract(5)
5
```
because the memory was not reset, `5` was subtracted from previous value `10`#### Division
For `divide`, zero division returns `None` and description
```python
>>> cal.divide(2)
2.5
```
```python
>>> cal.divide(0)
number cannot be zero => float division by zero
None>>> cal.memory_val
2.5
```#### Multiply
```python
>>> cal.multiply(2.5)
6.25
```
#### Modulo
```python
>>> cal.modulo(5)
1.25
```
#### Square root
```python
>>> cal.sqrt(16)
4
```#### Reset
```python
>>> cal.reset()
>>> cal.memory_val
0
```