Amazing-Python-Scripts icon indicating copy to clipboard operation
Amazing-Python-Scripts copied to clipboard

Implement basic arithmetic operations in calculator

Open pinnintipavankumar26-dot opened this issue 2 months ago • 2 comments

Description

Please include a summary of the change and which issue is fixed. List any dependencies that are required for this change.

Fixes #(issue_no)

Type of change

Please delete options that are not relevant.

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update
  • [ ] Documentation Update

Checklist:

  • [ ] My code follows the style guidelines(Clean Code) of this project
  • [ ] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have created a helpful and easy to understand README.md
  • [ ] My documentation follows Template for README.md
  • [ ] I have added the project meta data in the PR template.
  • [ ] I have created the requirements.txt file if needed.

Project Metadata

If there is no-file/nothing to fill the below fields with, then type: none

Example: If no requirements.txt needed/present, then type none in Requirments.

Category:

  • [ ] Calculators
  • [ ] AI/ML
  • [ ] Scrappers
  • [ ] Social_Media
  • [ ] PDF
  • [ ] Image_Processing
  • [ ] Video_Processing
  • [ ] Games
  • [ ] Networking
  • [ ] OS_Utilities
  • [ ] Automation
  • [ ] Cryptography
  • [ ] Computer_Vision
  • [ ] Fun
  • [ ] Others

Title: <write script title here>

Folder: <type the folder name that contains your script>

Requirements: <type the name of text file containing the required to install python packages, type None if no file required>

Script: <Enter the name of the .py file (The main entry point of the program)>

Arguments: <enter any arguments that the script needs but - separeted like: h-c-m>

Contributor: <Enter your Github handle/username without url>

Description: <Enter a one line description that describes your script. Also, explain the arguments usage here>

Summary by Sourcery

Implement a SimpleCalculator script with core arithmetic functions, zero-division handling, and sample output

New Features:

  • Add basic arithmetic operations (addition, subtraction, multiplication, division) in SimpleCalculator.py

Enhancements:

  • Handle division by zero in the divide function

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a SimpleCalculator script implementing basic arithmetic functions (add, subtract, multiply, divide with zero-check) and demonstrates their output via print statements.

Class diagram for SimpleCalculator functions

classDiagram
    class add {
        +add(a, b)
    }
    class subtract {
        +subtract(a, b)
    }
    class multiply {
        +multiply(a, b)
    }
    class divide {
        +divide(a, b)
    }

Flow diagram for SimpleCalculator script execution

flowchart TD
    A["Start"] --> B["Print 'Simple Calculator'"]
    B --> C["Call add(5, 3) and print result"]
    C --> D["Call subtract(5, 3) and print result"]
    D --> E["Call multiply(5, 3) and print result"]
    E --> F["Call divide(5, 3) and print result"]
    F --> G["End"]

File-Level Changes

Change Details Files
Implemented core arithmetic operations
  • Defined add(a, b) returning sum
  • Defined subtract(a, b) returning difference
  • Defined multiply(a, b) returning product
  • Defined divide(a, b) with division-by-zero guard
SimpleCalculator.py
Added demonstration of functionality
  • Printed script title
  • Printed results for addition, subtraction, multiplication, division
SimpleCalculator.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it. You can also reply to a review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment @sourcery-ai summary on the pull request to (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Nov 03 '25 02:11 sourcery-ai[bot]

Hi, this is my first pull request for Hacktoberfest practice. Please review and merge. 😊