Skip to main content

Calculator module

Project description

Calculator

Does basic math operations

Methods :

  • add - Adds the given number to the current number in the calculator memory
  • subtract - Subtracts the given number from the current number in the calculator memory
  • multiply - Multiplies current number in the calculator memory by the given number
  • divide - Divides current number in the calculator memory by the given number
  • root - Takes the given number root of the current number in the calculator
  • reset - Resets calculator memory, default: 0

Installation

pip install nershcalculator

Usage

Addition of numbers:

>>> from nershcalculator import Calculator
>>> calculations = Calculator()
>>> calculations.add(5)
'5.0'
>>> calculations.add(10)
'15.0'

Subtraction of numbers:

>>> from nershcalculator import Calculator
>>> calculations = Calculator()
>>> calculations.subtract(5)
'-5.0'
>>> calculations.subtract(10)
'-15.0'

Number multiplication:

>>> from nershcalculator import Calculator
>>> calculations = Calculator(5)
>>> calculations.multiply(10)
'50.0'
>>> calculations.multiply(5)
'250.0'

Number division:

>>> from nershcalculator import Calculator
>>> calculations = Calculator(5)
>>> calculations.divide(5)
'1.0'
>>> calculations.divide(5)
'0.2'

Taking n root out of a number:

>>> from nershcalculator import Calculator
>>> calculations = Calculator(125)
>>> calculations.root(3)
'5.0'

Resetting calculator:

>>> from nershcalculator import Calculator
>>> calculations = Calculator()
>>> calculations.add(100)
'100.0'
>>> calculations.reset()
'0.0'

Changelog

License

MIT

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

nershcalculator-0.3.1.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

nershcalculator-0.3.1-py2.py3-none-any.whl (2.6 kB view hashes)

Uploaded Python 2 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