Skip to main content

A simple calculator application.

Project description

Calculator package

This is a simple calculator application you can use in your projects to instantiate objects that behave like a basic calculators. The following Calculator() class methods accept a single integer. They perform a mathematical operation of your choice on a default value until you reset the object and initalize it to zero or a value of your choice:

.add(): computes the sum of the argument and the integer value in the object's memmory
.subtract(): computes the difference between the integer value in the object's memory and the argument
.multiply(): computes the product of the argument and the integer value in the object's memory
.divide(): computes the quotient of two integers; the argument serves as the divisor
.nth_root(): assign argument to n and finds the nth root of the integer value in the object's memory
.reset(): sets the value of the integer in the object's memory to 0 or the value of optional integer argument

To view Calculator class methods please use the dir() function on the object.

Installation and Setup

You must have pip and Python 3 or higher installed to use this package. Download the package from PyPi and use pip to install in the location of your choice. Import the calculator object from the calculator module in the package to your file.

Code structure

The package includes an init.py file and a calculator.py file. The calculator.py file was created in a Jupyter Notebook. The calculator.py file contains a single class, Calculator, that includes one static variable, default_num, that serves as the initialized value for the calculator. Like a conventional calculator, when you instantiate a Calculator object, default_num will equal 0. Use the Calculator() class to create your own Calculator object in your project (eg. my_calc = Calculator()) and use the methods described above to perform operations on the default_num.

Future work

The Calculator class included in this package can be improved upon by adding a try-except block to prevent Calculator objects from returning complex numbers when it attempts to divide by a negative number. Future developers could also raise exceptions when a developer attempts to pass non-integer arguments to the class methods. Precision could also be improved to prevent rounding errors when it performs operations.

Currently this package is designed to be used primarily by developers given that the package does not create calculator objects for the user. To make it more accessible to non-developers, the application could instantiate its own Calculator objects and a graphical user interface could be added, making the operations more explicit.

Ackowledgments

Thank you to Turing College Team Leaders and program participants for troubleshooting, insight, encouragement and a plethora of reference resources that helped me develop this package.

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_package_swhitt_tc-0.0.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

calculator_package_swhitt_tc-0.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file calculator_package_swhitt_tc-0.0.1.tar.gz.

File metadata

File hashes

Hashes for calculator_package_swhitt_tc-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5bc33b4290548fd90de8695e97972443ef99e07cd84aabef32137e6b871745cf
MD5 8f89d47e3030b2e38092a7b32cb9eb76
BLAKE2b-256 7d1fd3b73dda15a0d325ebca19d819f3d252890a4593b3b6d865117421c9bff5

See more details on using hashes here.

File details

Details for the file calculator_package_swhitt_tc-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for calculator_package_swhitt_tc-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d682ca8b5d71b516f8d65d8ea7963b95862a14d11aa8b776e4ca674dff125e0
MD5 2b8c001546f3ee536be28734b028996e
BLAKE2b-256 14d258bfd1f6e224648ed6c2d86c574b3f220553e94ea4cbcc4294055ab71d3c

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