Performs basic arithmetic operations
Project description
Calculator package
This package is a calculator class that performs basic arithmetical operations: addition, substraction, multiplication, devision and taking root.
Installation
You can install the package through pip:
pip install Calculator_tvaino
Usage
- Importing calculator to your Python project:
from Calculator import Calc
- Create an instance of the Calculator class:
Calc = Calculator()
- Perform arithmetic operations by calling the appropriate methods and store the to the memory:
- Addition: add(number)
- Subtraction: subtract(number)
- Multiplication: multiply(number)
- Division: divide(number)
- Square root: root(number)
Example:
calc.add(4) #adds 4 to the memory calc.divide(2) #devides the number of memory by 2
- Access the current result by calling the memory attribute "mem":
print(calc.mem) #prints the result of arithmetical operations stored in memory
- Clear the memory:
calc.reset #restets the memory to zero. Clear the memory before starting a new sequence of arithmetic operations!
- Example:
# Import Calculator
from Calculator import Calculator
# Create a Calculator instance.
calc = Calculator()
# Perform arithmetic operations.
calc.add(5)
calc.multiply(3)
calc.divide(2)
# Access the result.
print("Result:", calc.mem) # Output: 7.5
# Reset the memory.
calc.reset()
# Perform another operation.
calc.root(16)
# Access the result.
print(calc.mem) # Output: 4.0
#Tests performed
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
File details
Details for the file Calculator_tvaino-0.0.6.tar.gz.
File metadata
- Download URL: Calculator_tvaino-0.0.6.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
641acc1e0fd7c29298075380bbfb33bc1ac1f0658a8e89e4a37e4daa3abfe696
|
|
| MD5 |
866d90b47d96f2d2bb4fd467c189a217
|
|
| BLAKE2b-256 |
c4fb1bc8b7749db8b636794be105fc86c45fea377a5f9f6838b552728d60b3c6
|