Skip to main content

Basic Python Calculator

Project description

Basic Calculator

A basic Python class for arithmetic calculations. Calculator performs simple arithmetic calculations:

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

Installation

You can incorporate the Calculator class into your Python project by importing it :

Installation

You can incorporate the Calculator class into your Python project by importing it :

  pip install calculator_linpel_calc

Usage/Examples

Setting up a calculator

To set up Calculator calss by importing Calculator from calculator_linpel_calc and creating an instance.

from Calculator.Calculator import Calculator

# Creata an instance of the Calculator
calculator = Calculator()

Executing Calculator operations

The Calculator class able is able to perform calculations:

  • Addition(*arg: float): Sum numbers.
  • Subtraction(*arg: float): Subtract numbers.
  • Multiplication(*arg: float): Multiply numbers together.
  • Division(*arg: float): Divide numbers.
  • Root(nth_root: float, number: float): Take nth root of number. Example of Usage
calculator = Calculator()

calculator.Addition(1, 2, 3)    # Adds 1, 2, 3, result: 6.0
calculator.Subtraction(1, 2, 3) # Subracts 1, 2, 3 from self.memory = 0, result: -6.0
calculator.Multiplication(7, 3) # Multiplies 7 by 3, result: 21.0
calculator.Division(9, 3)       # Divides 9 by 3, result: 3.0
calculator.Root(2, 9)           # Takes n-th root (2) of 9, result: 3.0

Error Handling

The Calculator class raises a ZeroDivisionError when attempting to divide by zero, or 0 root calculations.

License

This code is released under the MIT License

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

calculator_linpel_calc-0.1.4.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

calculator_linpel_calc-0.1.4-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file calculator_linpel_calc-0.1.4.tar.gz.

File metadata

  • Download URL: calculator_linpel_calc-0.1.4.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for calculator_linpel_calc-0.1.4.tar.gz
Algorithm Hash digest
SHA256 429e636a571dd0f0ab5695dafb3c95109b57a3ac663beafb168e2335f8b49ad9
MD5 75695a636c6fe6fe43bf7ebfd5f0026c
BLAKE2b-256 22cc25559af63146ea1680c07050b9ae166ade9bd7f30191f71519a0fc2f8a96

See more details on using hashes here.

File details

Details for the file calculator_linpel_calc-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for calculator_linpel_calc-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 32b6a39fe9d8bcba56e56bff3384185fc5a813c596a8bf1caf2bdec9d7417f9f
MD5 4b687760af28dccbacb08e8a45abeb10
BLAKE2b-256 e175da827bd87adbd5938576aac026760579703644ec8ba6103cf263e27d3765

See more details on using hashes here.

Supported by

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