-
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
Changes from all commits
4f38e0d
19d2c4b
b95c198
1352317
4fc29d6
4caf9f0
f9813de
33a41ae
a22a36e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,25 @@ | ||||||||||||||||
| from operator import add, sub, mul | ||||||||||||||||
|
|
||||||||||||||||
| def calc(): | ||||||||||||||||
| op = input("Enter operator +-*: ") | ||||||||||||||||
| n1 = int(input('Fist number: ')) | ||||||||||||||||
| n2 = int(input('Second number: ')) | ||||||||||||||||
| operators = {'+': add(n1, n2), '-': sub(n1, n2), '*': mul(n1, n2)} | ||||||||||||||||
| if op in operators: | ||||||||||||||||
| print('{} {} {} = {}'.format(n1, op, n2, operators[op])) | ||||||||||||||||
|
Comment on lines
+7
to
+9
|
||||||||||||||||
| 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)) |
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:'.