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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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