Skip to main content

The Calculator Package

Table of contents

  • Summary
  • Requirements
  • Installation
  • Usage
  • License

Summary

This package contains a class Calculator which allows to perform basic mathematical operations while saving the obtained result in memory for further calculations.

It includes methods for the following operations:

  • Addition / Subtraction
  • Multiplication / Division
  • Take (n) root of a number
  • Reset memory

Requirements

  • Python 3.6 or newer

Installation

To install the package:

pip install gkamin-calculator

Usage

This section will detail all the methods that can be called for the created object Calculator.

However, in order to use the methods, first we need to import the package:

>>>> from gkamin_calculator.gkamin_calculator import Calculator

Creating the calculator object

When the calculator object is created, the initial value it stores is equal to zero:

>>>> calc = Calculator() 
>>>> print(calc.result)
0

Initial value can be changed by using optional input parameter:

>>>> calc = Calculator(10.05)
>>>> print(calc.result)
10.05

Addition method

.add(addend) - this method adds input value to last stored result. Initially to 0:

>>>>calc = Calculator()
>>>>calc.add(2)
>>>>print(calc.result)
2
>>>>print(calc.result)
2
>>>>calc.add(3)
>>>>print(calc.result)
5

Subtraction method

.subtract(subtrahend) - this method subtracts input value from last stored result:

>>>>print(calc.result)
5
>>>>calc.subtract(1)
>>>>print(calc.result)
4

Multiplication method

.multiply(multiplier) - this method multiplies input value by last stored result:

>>>>print(calc.result)
4
>>>>calc.multiply(4)
>>>>print(calc.result)
16

Division method

.divide(divisor) - this method divides last stored result by input value:

>>>>print(calc.result)
16
>>>>calc.divide(2)
>>>>print(calc.result)
8

Root method

.root(degree_of_root) - this method extracts n-th root from last stored result, where n is degree of root.

>>>>print(calc.result)
8
>>>>calc.root(3)
>>>>print(calc.result)
2

.root(degree_of_root, radicand) - if this is the first operation performed (initially radicand is equal to 0), optional input value to be used to set required radicand value:

>>>>calc = Calculator()
>>>>calc.root(4, 64)
>>>>print(calc.result)
4

Reset method

.reset(self) - this method resets the last stored result to zero:

>>>>calc.reset()
>>>>print(calc.result)
0

License

This project is licensed under the MIT License. See the LICENSE.txt for details.

Metadata

Release files for gkamin-calculator 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gkamin-calculator 0.0.5
File Size Uploaded
gkamin_calculator-0.0.5.tar.gz 3.8 kB Details

Release files / gkamin_calculator-0.0.5.tar.gz

Download URL gkamin_calculator-0.0.5.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9e11604ebd0eae409c2b76865a441d7d36dd27b43b477a527fd44fa9ca25855a
BLAKE2b-256 checksum
How to use checksums
f292ef4f847c0dea3c7b8a892780b4033f33c21b6126c1c6e845a8f89556c078
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.2

Release history Release notifications | RSS feed

This release

0.0.5 This release

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page