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 calculator app #13

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

Create calculator app #13

wants to merge 6 commits into from

Conversation

PavelLinearB
Copy link
Member

@PavelLinearB PavelLinearB commented Feb 23, 2025

workerB

✨ PR Description

Purpose: Implements a basic command-line calculator with support for addition, subtraction, multiplication, and division operations.

Main changes:

  • Created four basic arithmetic functions with error handling for division by zero
  • Implemented operations dictionary to map user choices to functions and symbols
  • Added interactive main loop with user input validation and calculation repetition option

Generated by LinearB AI and added by gitStream

Copy link

gitstream-cm bot commented Feb 23, 2025

✨ PR Review

Maintainability - calc/calc.py

Details:

Problem: Function docstrings are simple comments that don't follow standard Python documentation practices
Fix: Convert comments to proper docstrings with parameter and return type information
Why: Proper docstrings enable better IDE integration and documentation generation

-# This function adds two numbers
def add(x, y):
+def add(x, y):
+    """
+    Add two numbers together.
+    
+    Args:
+        x (float): First number
+        y (float): Second number
+    
+    Returns:
+        float: The sum of x and y
+    """
    return x + y

User Experience - calc/calc.py

Details:

Problem: Program ends abruptly without notification
Fix: Add exit message when user chooses to stop
Why: Improves user experience by providing clear program termination

            if next_calculation == "no":
+                print("Thanks for using the calculator. Goodbye!")
                break

Security - calc/calc.py

Details:

Problem: No handling of keyboard interrupts could leave program in unexpected state
Fix: Add try-except block for KeyboardInterrupt in main loop
Why: Ensures graceful program termination when user presses Ctrl+C

def main():
+    try:
        print("Select operation.")
        print("1.Add")
        print("2.Subtract")
        print("3.Multiply")
        print("4.Divide")
    
        while True:
            # rest of the code...
+    except KeyboardInterrupt:
+        print("\nProgram terminated by user")

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