Skip to main content

A Python package for basic arithmetic operations.

Project description

Calcat Calculator Package

A Python package for basic arithmetic operations. This package provides a Calculator class that allows users to perform addition, subtraction, multiplication, division, exponentiation, and extraction of roots. The Calculator class also features memory functionality, allowing users to store and manipulate results.

Installation

You can install the calculator package using pip:

pip install calcat

You can also explore the package on Google Collab: Link.

Calcat package on PyPI: Link

Usage

Basic Usage

from calcat import Calculator

# Create a calculator object
calc = Calculator()

# Perform arithmetic operations
result = calc.add(5, 3)  # Addition: 5 + 3
print(result)  # Output: 8

result = calc.subtract(5, 3)  # Subtraction: 5 - 3
print(result)  # Output: 2

result = calc.multiply(5, 3)  # Multiplication: 5 * 3
print(result)  # Output: 15

result = calc.divide(15, 3)  # Division: 15 / 3
print(result)  # Output: 5

result = calc.power(5, 3)  # Raising to the power: 5 ** 3
print(result)  # Output: 125

result = calc.root(8, 3)  # Root extraction: 3 √ 8
print(result)  # Output: 2

Command-Line Interface (CLI)

You can also use the calculator from the command line. After installation run in your terminal:

$ python
$ from calcat import Calculator
$ calc = Calculator()
$ calc.perform_operation()

This will start an interactive session where you can choose operations and input numbers directly in the terminal.

Available Operations

  • Addition: calc.add(x, y) - Adds x and y.
  • Subtraction: calc.subtract(x, y) - Subtracts y from x.
  • Multiplication: calc.multiply(x, y) - Multiplies x and y.
  • Division: calc.divide(x, y) - Divides x by y.
  • Exponentiation: calc.power(x, y) - Raises x to the power of y.
  • Root Extraction: calc.root(x, y) - Extracts the y-th root from x.

Memory Functionality

The Calculator class has a built-in memory. The result of the last operation is stored in the memory and can be accessed using calc.memory. You can reset the memory to 0 using calc.reset_memory().

# Example of memory usage
result = calc.add(2, 3)  # Result = 5, memory = 5
print(calc.memory)  # Output: 5

calc.reset_memory()  # Reset the memory to 0
print(calc.memory)  # Output: 0

Developing Calcat

To install calcat, along with the tools you need to develop and run tests, run the following in your virtualenv:

$ pip install -e .[dev]

License

This project is licensed under the MIT License - see the LICENSE file for details.

For more information, visit the GitHub repository.

Feel free to contribute and report issues!

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

calcat-1.0.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

calcat-1.0.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file calcat-1.0.1.tar.gz.

File metadata

  • Download URL: calcat-1.0.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for calcat-1.0.1.tar.gz
Algorithm Hash digest
SHA256 698c38bde970641b383fc200bffb5d9090b05bdf7d5f0d4b5b4f1da9f337f654
MD5 65f8debb1f29765d325000a24a17afd0
BLAKE2b-256 28b4a4331363b8fd55232393828680ff8cda5212c0a13c10924128f2ecb5190e

See more details on using hashes here.

File details

Details for the file calcat-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: calcat-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for calcat-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 37ad73ccee9afa4b0edeba1b51c6f6a0cdb9246c8de63c32624dc3d27d3fcdcd
MD5 4df9acf61dd99135fb58e6e498acc882
BLAKE2b-256 32ce54572361008cb3ea83b80e3d67eef0de660a6c5e4cbda621c0f042b8d79b

See more details on using hashes here.

Supported by

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