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.src.calcat.calculator 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
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)
- Addsx
andy
. - Subtraction:
calc.subtract(x, y)
- Subtractsy
fromx
. - Multiplication:
calc.multiply(x, y)
- Multipliesx
andy
. - Division:
calc.divide(x, y)
- Dividesx
byy
. - Exponentiation:
calc.power(x, y)
- Raisesx
to the power ofy
. - Root Extraction:
calc.root(x, y)
- Extracts they
-th root fromx
.
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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.