Conversation
|
Please mark which AI tools you used for this PR by checking the appropriate boxes:
Tip: If you want to avoid this comment in the future, add a label of the format "🤖 ai-*" when creating your PR, or ask your admin to add you to the pre-defined lists of known users |
|
Changelog: Request failed with status 500: Internal Server Error |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a basic calculator program with a menu-driven interface to perform arithmetic operations.
- Implements a calculator function performing addition, subtraction, and multiplication
- Creates a simple menu to drive user interaction and program flow control
|
|
||
| def calc(): | ||
| op = input("Enter operator +-*: ") | ||
| n1 = int(input('Fist number: ')) |
There was a problem hiding this comment.
Typo detected: 'Fist number:' should be corrected to 'First number:'.
| n1 = int(input('Fist number: ')) | |
| n1 = int(input('First number: ')) |
| operators = {'+': add(n1, n2), '-': sub(n1, n2), '*': mul(n1, n2)} | ||
| if op in operators: | ||
| print('{} {} {} = {}'.format(n1, op, n2, operators[op])) |
There was a problem hiding this comment.
[nitpick] The dictionary currently precomputes all operations regardless of the selected operator. Consider mapping operator symbols to the corresponding function (e.g., {'+': add, ...}) and then computing the result after determining the operator to improve efficiency and consistency.
| operators = {'+': add(n1, n2), '-': sub(n1, n2), '*': mul(n1, n2)} | |
| if op in operators: | |
| print('{} {} {} = {}'.format(n1, op, n2, operators[op])) | |
| operators = {'+': add, '-': sub, '*': mul} | |
| if op in operators: | |
| result = operators[op](n1, n2) | |
| print('{} {} {} = {}'.format(n1, op, n2, result)) |
✨ PR Description
Purpose: This PR introduces a basic calculator program with a menu-driven interface for performing arithmetic operations.
Main changes:
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We’d love your feedback! 🚀