Skip to main content

Package of a calculator using an internal memory

Project description

Requirements

The main package file should contain a class Calculator that should be able to perform these actions:

Addition / Subtraction.

Multiplication / Division.

Take (n) root of a number.

Reset memory (Calculator must have its own memory, meaning it should manipulate its starting number 0 until it is reset.).

This means that, for example, calculator should perform actions with a value inside its memory (for this example, the value inside the calculator's memory is 0): calculator.add(2) results in 2.

Realization

Calculator class object for the operations uses the following methods:

    addition: plus method is used

    subtraction: minus method

    multiplication: multiply method

    division: divide method

    take (n) root of a number: root method

    reset memory: reset method

Calculator class has an attribute called memory, performing actions above on it with memory's starting value 0.0 until the memory is reset.

Thus, all methods above require just one argument, except reset method for which the argument is optional and without it memory is set to the default value of 0.0.

For example,

    calculator.plus(2) adds 2 to the memory

    calculator.minus(5) subtracts 5 from the memory

    calculator.multiply(10) multiplies the memory by 10

    calculate.divide(3) divides the memory by 3

    and calculator.root(4) takes 4th root of the memory

Reset method calculator.reset(0) by default sets the memory to 0.0, but it is allowed to set the memory to the desired value, providing an optional argument as calculator.reset(desired_value).

Calculator works with integer and float numbers, a validation is performed before the methods are used. Calculator also prevents from division by zero and a root operation on a negative number. In such cases an operation is not performed and a relevant assertion error message is provided.

Package and files

https://pypi.org/project/calc-with-mem/

To start using install the package use:

pip install calc-with-mem

Following the requirements, the package contains already described Calculator() class.

The files submitted:

README.MD - this file

calc_with_mem - folder with the main calc_with_memory.py module (comments are present in the document) and files to create a package

test.py - unittest checks are performed to test the calculator (comments are also present in the document)

LICENCE.TXT - MIT licence defined

setup.py - used to create a package

The calculator was also tested on Google Colab and calc_with_mem.ipynb file added.

The file 115.ipynb was uploaded by Turing College.

PyCharm 2022.3.2 (Community Edition) was used for the project, and the codes submitted are in compliance with PEP 8 requirements.

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

calc_with_mem-0.8.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

calc_with_mem-0.8-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file calc_with_mem-0.8.tar.gz.

File metadata

  • Download URL: calc_with_mem-0.8.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for calc_with_mem-0.8.tar.gz
Algorithm Hash digest
SHA256 cb2821e626fa10dc74a7155883a065a814a9edd7d140449e8b3ccd233a85f516
MD5 50edb81e1d14e3980595142bbb5dfbf1
BLAKE2b-256 955badcbd8ef23588e1b7106cd7e29998444ee6a71945dbbee2ff95207a88dc7

See more details on using hashes here.

File details

Details for the file calc_with_mem-0.8-py2.py3-none-any.whl.

File metadata

  • Download URL: calc_with_mem-0.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for calc_with_mem-0.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a498bdf85ba35a094757f9804f8ee9e8cb7affa1b36962cb9bcbbd3ff849925d
MD5 006d86d428c3be7d4f53256df117205d
BLAKE2b-256 f7b5fe7f1d1f027ace3229f95c4b0f3cc34865449e847392a87557444e20ba35

See more details on using hashes here.

Supported by

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