Skip to main content

A Scientific calculator

Project description

Scientific Python Calculator

Scientific Python Calculator (scipy_calculator) is a library for doing mathematics computation. It works similar to a calculator.

:raised_hands: This is my first python package. It will be improved over time. Feel free to contribute to this beautiful work of art.

Installation

:warning: scipy_calculator is only tested with python 3.

Installation via PYPI

$ pip install scipy-calculator

Installation via Github this is for the stable released version

$ pip install git+https://github.com/komus/scipy_calculator

scipy_calculator uses multipledispatch dependency and pytest for automated test

Usage

The calculator can be used for basic mathematical computation. The calculator has a memory that caches the last result until it is reset. The cached result is used in the next computation if not reset.

The reset is used to clear the cache

Examples will be shown below

Sample Code

from calculator import Calculator

my_cal = Calculator()

Addition

sum method accepts list, int, float

>>> my_cal.sum(10, 2)
12
>>> my_cal.sum(2)
14
>>> my_cal.sum([10, 12.90, 14, 5, 7])
62.9

Because the calculator memory wasn't reset, 2 was added to the result of 10+2. The result 14 was added to list

>>> my_cal.reset
>>> my_cal.sum(3, 2)
5

Subtraction

subtract

>>> my_cal.subtract(5)
-5
>>> my_cal.reset
>>> my_cal.subtract(10, 4)
6
>>> my_cal.subtract(2)
4
>>> my_cal.subtract(3, 1)
0

Multiply

>>> val = [2, 4, 5, 2, 1]
>>> my_cal.multiply(1000)
1000
>>> my_cal.multiply(val)
80
>>> my_cal.multiply(12, 2)
24
>>> my_cal.subtract(4)
20

Division

For divide, zero division returns err

>>> my_cal.divide(100, 5)
20
>>> my_cal.sum(10)
30
>>> my_cal.divide(2)
15
>>> my_cal.divide(0)
err
>>> my_cal.divide(0, 78)
0

Average

average method accepts LIST of int and float to return the computed average

>>> grade = [62, 78.9, 35.78, 90.23, 89.12, 45.78]
>>> avg_grade = my_cal.average(grade)
>>> avg_grade
66.96833333333335

Adding or subtracting without reseting, will add/subtract the value from the last result

>>> my_cal.sum(10)
76.96833333333335

Modulo

For modulo, zero division returns err

>>> my_cal.modulo(10, 2)
0
>>> my_cal.modulo(15, 4)
3
>>> my_cal.modulo(10, 0)
err
>>> my_cal.modulo(14.67, 3)
2.67

Root

>>> my_cal.root(27, 3)
3
>>> my_cal.root(32, 5)
2

Power

>>> my_cal.power(5, 3)
125
>>> my_cal.power(3.5, 3)
42.875
>>> my_cal.power(2, 5)
32

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

scipy_calculator-0.0.4.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

scipy_calculator-0.0.4-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file scipy_calculator-0.0.4.tar.gz.

File metadata

  • Download URL: scipy_calculator-0.0.4.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2

File hashes

Hashes for scipy_calculator-0.0.4.tar.gz
Algorithm Hash digest
SHA256 4c4da3cb2aeb0c3f5934cbea8300089494d8733c6f834c9c3d16d24f5deb97d2
MD5 b251a94cf3aed116585548a10e2d362e
BLAKE2b-256 6fd455e33eaac2c3dc2b41d037b57fba7bd0a7bb437a17516bfa544d889939f9

See more details on using hashes here.

File details

Details for the file scipy_calculator-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: scipy_calculator-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2

File hashes

Hashes for scipy_calculator-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4fbd7f651f720af154f168a50207144c7f1c97c504054fa09701879d06f0abdb
MD5 b2a99a9e4cb67e6b1c5b4a2f6879c2cc
BLAKE2b-256 6dd1b1f5768b0ba80fea4304023303707c9ecb17e556968985762a9df223a0d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page