DS.v3.1.2.5

Naga Pratyusha Duvvuri

DS.v3.1.2.5

Calculator Module

Calculator Package

The Calculator package provides a simple calculator class with basic arithmetic operations, memory functionality, and additional capabilities like taking roots. This package is designed for easy integration into Python projects where basic arithmetic operations are needed.

Features

Addition: Add a number to the current memory.
Subtraction: Subtract a number from the current memory.
Multiplication: Multiply the current memory by a number.
Division: Divide the current memory by a number (with error handling for division by zero).
Nth Root: Take the nth root of the current memory.
Memory Reset: Reset the memory to zero.

Installation

To install the calculator.py package, you can simply download the file or clone the repository to your local machine:
git clone <repository-url>
Alternatively, if the package is available on PyPI, you can install it using pip:
pip install calculator

Usage

To use the Calculator class, you need to import the class from the calculator.py file and then create an instance of the class. Here’s an example of how to use each method:
Importing the Calculator
from calculator import Calculator
2. Creating an Instance
calc = Calculator()
3. Performing Operations
Addition
Subtraction
Multiplication
Division
Nth Root
Resetting Memory

Example Workflow

Here is a complete example that demonstrates the typical workflow using the Calculator class:
from calculator import Calculator calc = Calculator() # Create an instance of Calculator calc.add(15) # Add 15 to memory calc.subtract(5) # Subtract 5 from memory calc.multiply(3) # Multiply memory by 3 calc.divide(2) # Divide memory by 2 calc.take_root(3) # Take the cube root of memory calc.reset_memory() # Reset memory to 0
Like this project

Posted Oct 17, 2024

Contribute to pratyusha1213/Python-Projects development by creating an account on GitHub.

Crop Bidding Project
Crop Bidding Project
Spotify Top 50 Tracks of 2020 Analysis
Spotify Top 50 Tracks of 2020 Analysis

Join 50k+ companies and 1M+ independents

Contra Logo

© 2025 Contra.Work Inc