Skip to main content

A simple calculator package

Project description

Calculator

This is a lightweight calculator package for performing simple calculation operations such as addition, subtraction, multiplication, division, root, and reset. For each operation, it takes only one input number and combines it with the current value in the calculator memory. The memory value can be reset at any time.


Features

  • Addition : Adds input value to memory value
  • Subtraction : Subtracts input value from memory value
  • Multiplication : Multiplies input value by memory value
  • Division : Divides input value by memory value
  • Root : Returns the input value root of the memory value
  • Reset : Resets memory value to zero

Technology/Tools

  • Python : To build the package
  • Docker : To containerize the package
  • Pytest : To test the package

Installation

Run any of the commands below for installation:

  • To install the package from PyPI
$ python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps calculator-halimah
  • To install from github
$ pip install git+https://github.com/halimahO/calculator.git
  • To get image from dockerhub
$ FROM haleemah/calculator

Contribution

To contribute or extend this package

  • Clone the package using git clone https://github.com/halimahO/calculator.git
  • Install dependencies using pip install -r requirements.txt
  • Run the project using src/calculator/python calculator.py
  • Run the tests using tests/pytest
  • Add contributions or make changes
  • Write tests if required
  • Run tests again to ensure the changes doesn't break anything
  • Push the changes to a new branch
  • Raise a pull request

Sample Usage

This calculator always uses the memory value as the start value, remember to reset to start a new calculation. For example:

  • 2 + 3 -- Will start by running add 2, then add 3
  • 4 - 2 -- Will start by running add 4, then subtract 2
  • 2 * 5 -- Will start by running add 2, then multiply 5
  • 6 * 3 -- Will start by running add 6, then divide 3
  • 3√4 -- Will start by running add 4, then root 3

Usage example for each method is given below

from calculator.calculator import Calculator
calculator = Calculator()

$ calculator.add(5)

$ calculator.subtract(3)

$ calculator.multiply(3)

$ calculator.divide(3)

$ calculator.root(2)

$ calculator.reset()

Testing

To run the tests, cd to 'tests' directory and run

$ pytest

Acknowledgement

Turing College


License

This project is licensed under the terms of the MIT license


Author

Halimah Oladosu

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

calculator-halimah-0.0.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

calculator_halimah-0.0.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file calculator-halimah-0.0.2.tar.gz.

File metadata

  • Download URL: calculator-halimah-0.0.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for calculator-halimah-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ea57f99810c1b63810b86b3e41e5d06022259c34e6d19ed6a820315970245b4c
MD5 827386804c00165f94cfe8a74e76556c
BLAKE2b-256 fcd7aeabcdb1063e1f234038c21c88e767835a6c2fc45f4ef30792eddf820f45

See more details on using hashes here.

File details

Details for the file calculator_halimah-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: calculator_halimah-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for calculator_halimah-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3d17a14479187a388ccd088a68dfed596b6c904b9ce8532cba6e37317e8b40c9
MD5 9c585b41894e66a8d3d5053e0d27fbee
BLAKE2b-256 5360966e25e546de1248ed76ddbb574801c417f914c0d2546c4d0a3f2f9bf3e8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page