Skip to main content

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

  1. Importing calculator to your Python project:

from Calculator import Calculator

  1. Create an instance of the Calculator class:

Calc = Calculator()

  1. 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

  1. Access the current result by calling the memory attribute "mem":

print(calc.mem) #prints the result of arithmetical operations stored in memory

  1. Clear the memory:

calc.reset #restets the memory to zero. Clear the memory before starting a new sequence of arithmetic operations!

  1. 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

calculator_tvaino-0.0.14.tar.gz (3.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_tvaino-0.0.14-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

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

Hashes for calculator_tvaino-0.0.14.tar.gz
Algorithm Hash digest
SHA256 371cd5a79d6d9a777e4f6c0b3011fbd104688fc61ae7e1a9ac0cc0fcf166da1e
MD5 75124730bb02d3fcc3a7cfab7c92be2d
BLAKE2b-256 95fd8455559a192459b2cbbfc6ca39f0c6ae7427ff7cdefe89fec1326dd0b3d2

See more details on using hashes here.

File details

Details for the file Calculator_tvaino-0.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for Calculator_tvaino-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 762ac66711845d416b74fe0bae5459109966434b957cb90ee0e010485eec417f
MD5 4387e8e394e6aa507af054199a9d2072
BLAKE2b-256 2d3b0b9265fc67d5c685f76a4866c5217726cdcf14583f22962857ad96963151

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