-
Notifications
You must be signed in to change notification settings - Fork 0
Create cc.py #111
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
base: main
Are you sure you want to change the base?
Create cc.py #111
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo detected: 'Fist number:' should be corrected to 'First number:'.
n1 = int(input('Fist number: ')) | |
n1 = int(input('First number: ')) |
Copilot uses AI. Check for mistakes.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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)) |
Copilot uses AI. Check for mistakes.
✨ 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! 🚀