A simple calculator to perform basic arithmetic operations and root calculations.
Project description
This project provides a simple calculator class that can perform basic arithmetic operations and root calculations.
Class: Calculator The Calculator class performs the following operations:
Addition Subtraction Multiplication Division Nth Root Calculation
Methods:
init(self, number_1: float, number_2: float): Initializes the calculator with two numbers. add(self) -> float: Adds the two numbers. subtract(self) -> float: Subtracts the second number from the first number. multiply(self) -> float: Multiplies the two numbers. divide(self) -> float: Divides the first number by the second number. nroot(self) -> float: Calculates the nth root of the first number based on the second number. decision(self, user_decision: str) -> float: Performs the operation based on the user's decision. reset(self): Resets the memory to zero.
Installation To install the project, you need to have Python installed. Then, you can set up the project using pyproject.toml.
Example Usages; from calculator.calculator import Calculator
Create a Calculator object
calc = Calculator(10, 5)
Perform operations
print(calc.add().memory) # Output: 15 print(calc.subtract().memory) # Output: 5 print(calc.multiply().memory) # Output: 50 print(calc.divide().memory) # Output: 2.0 print(calc.nroot().memory) # Output: 1.5848931924611136
Chaining operations
calc.reset().number_1 = 10 calc.number_2 = 5 print(calc.add().subtract().multiply().divide().memory) # Output: 2.0
Reset the calculator
calc.reset() print(calc.memory) # Output: 0.0
Print calculator value
print(str(calc)) # Output: 0.0
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.
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_project-0.1.0.tar.gz.
File metadata
- Download URL: calculator_project-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
480655f9eb658834c66b5ffa540d13dd3a6d5c5ebd1ed99e6756b631c5b2b604
|
|
| MD5 |
5106aa44c1621197f769faf0fee2d724
|
|
| BLAKE2b-256 |
7028a7a3f9ed5c54b184b0c676d51c8b05a99df2c2c051e41fa0933732803e0a
|
File details
Details for the file calculator_project-0.1.0-py3-none-any.whl.
File metadata
- Download URL: calculator_project-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9713b71e40043b840b164229adb441aa3112abee2f68ca6a1a9cdfc272cc31ef
|
|
| MD5 |
5f09698061b8674cdc7e824a9c74fcac
|
|
| BLAKE2b-256 |
5c2916801cc7d2172e3fa7b212361cbac31e1fee5081625c360382ecea6a1b17
|