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.
Metadata
Release files for calculator-package-swhitt-tc 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| calculator_package_swhitt_tc-0.0.1.tar.gz | 3.2 kB | Without provenance | Details for calculator_package_swhitt_tc-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| calculator_package_swhitt_tc-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for calculator_package_swhitt_tc-0.0.1-py3-none-any.whl |
Total release size: 7.3 kB
Release files / calculator_package_swhitt_tc-0.0.1.tar.gz
| Download URL | calculator_package_swhitt_tc-0.0.1.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5bc33b4290548fd90de8695e97972443ef99e07cd84aabef32137e6b871745cf
|
|
BLAKE2b-256 checksum How to use checksums |
7d1fd3b73dda15a0d325ebca19d819f3d252890a4593b3b6d865117421c9bff5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.1
|
Release files / calculator_package_swhitt_tc-0.0.1-py3-none-any.whl
| Download URL | calculator_package_swhitt_tc-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d682ca8b5d71b516f8d65d8ea7963b95862a14d11aa8b776e4ca674dff125e0
|
|
BLAKE2b-256 checksum How to use checksums |
14d258bfd1f6e224648ed6c2d86c574b3f220553e94ea4cbcc4294055ab71d3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.1
|
Security for calculator-package-swhitt-tc 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.