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 Calculator
- 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 value calc.divide(2) #devides the value of memory by 2 calc.multiply(3) #multiplies the value of memory by 3 calc.dvivde(4) #devides the value of memory by 4 calc.root(3) #takes cube root of the memory value
- 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_tvaino.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()
# Take square root of the memory value
calc.root(2)
# 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file calculator_tvaino-0.0.14.tar.gz.
File metadata
- Download URL: calculator_tvaino-0.0.14.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
371cd5a79d6d9a777e4f6c0b3011fbd104688fc61ae7e1a9ac0cc0fcf166da1e
|
|
| MD5 |
75124730bb02d3fcc3a7cfab7c92be2d
|
|
| BLAKE2b-256 |
95fd8455559a192459b2cbbfc6ca39f0c6ae7427ff7cdefe89fec1326dd0b3d2
|
File details
Details for the file Calculator_tvaino-0.0.14-py3-none-any.whl.
File metadata
- Download URL: Calculator_tvaino-0.0.14-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
762ac66711845d416b74fe0bae5459109966434b957cb90ee0e010485eec417f
|
|
| MD5 |
4387e8e394e6aa507af054199a9d2072
|
|
| BLAKE2b-256 |
2d3b0b9265fc67d5c685f76a4866c5217726cdcf14583f22962857ad96963151
|