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.


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


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]


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 hashes)

Uploaded Source

Built Distribution

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

Uploaded 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