Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create calc.py #9

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Create calc.py #9

wants to merge 2 commits into from

Conversation

PavelLinearB
Copy link
Member

@PavelLinearB PavelLinearB commented Feb 19, 2025

✨ PR Description

Purpose: Implements a basic command-line calculator that performs four fundamental arithmetic operations.

Main changes:

  • Added four core arithmetic functions (add, subtract, multiply, divide)
  • Implemented user input handling with error checking for invalid inputs
  • Created interactive loop allowing multiple calculations with option to exit

Generated by LinearB AI and added by gitStream

@PavelLinearB PavelLinearB changed the title Create calc.py Create calc.py Feb 20, 2025
Copy link

gitstream-cm bot commented Feb 20, 2025

✨ PR Review

Bug - calc/calc.py (Line 14)

Details:

Problem: No handling for division by zero
Fix: Add zero division check in divide function
Why: Prevents program crash and provides better user feedback

def divide(x, y):
+    if y == 0:
+        raise ValueError("Cannot divide by zero")
    return x / y

Bug - calc/calc.py (Line 47)

Details:

Problem: Next calculation check is case-sensitive and only checks for "no"
Fix: Convert input to lowercase and check for variations of yes/no
Why: Improves user experience by accepting common input variations

-        next_calculation = input("Let's do next calculation? (yes/no): ")
-        if next_calculation == "no":
+        next_calculation = input("Let's do next calculation? (yes/no): ").lower()
+        if next_calculation not in ('y', 'yes'):
           break

Generated by LinearB AI and added by gitStream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant