Skip to main content

Performs 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 Calc

  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 calc.divide(2) #devides the number of memory by 2

  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 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()

# Perform another operation.
calc.root(16)

# 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.5.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file Calculator_tvaino-0.0.5.tar.gz.

File metadata

  • Download URL: Calculator_tvaino-0.0.5.tar.gz
  • Upload date:
  • Size: 2.8 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.5.tar.gz
Algorithm Hash digest
SHA256 f336dc72db4078c62a07712e552f5c88900fee6ba13b5d838a08cae5336b2333
MD5 7cd55ff396c8c6c56255a8ff86dec387
BLAKE2b-256 292ca2146ca4ded3cbe70ee7d012c175d50d12d2d5b3f26b538529312f9ee3e3

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