Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
DELGADO VALENCIA, JORGE
ptavi-p2
Commits
7f391145
Commit
7f391145
authored
Sep 29, 2015
by
muris2016
Browse files
Nombres de variables mejorados
parent
e914b4ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
calcoo.py
View file @
7f391145
...
...
@@ -9,8 +9,8 @@ class Calculadora:
def
__init__
(
self
):
self
.
operations
=
{
"suma"
:
self
.
sum
,
"resta"
:
self
.
substraction
}
def
operating
(
self
,
calc
ulator
_operation
,
op1
,
op2
):
return
calc
ulator
_operation
(
op1
,
op2
)
def
operating
(
self
,
calc_operation
,
op1
,
op2
):
return
calc_operation
(
op1
,
op2
)
def
sum
(
self
,
a
,
b
):
return
a
+
b
...
...
@@ -19,10 +19,10 @@ class Calculadora:
return
a
-
b
def
do_operation
(
calc
ulator
,
operation
,
op1
,
op2
):
def
do_operation
(
calc
,
operation
,
op1
,
op2
):
try
:
return
calc
ulator
.
operating
(
calc
ulator
.
operations
[
operation
],
return
calc
.
operating
(
calc
.
operations
[
operation
],
op1
,
op2
)
except
KeyError
:
sys
.
exit
(
"Not allowed operation "
+
operation
)
...
...
@@ -31,5 +31,5 @@ if __name__ == "__main__":
op1
=
calc
.
to_number
(
sys
.
argv
[
1
])
operation
=
sys
.
argv
[
2
]
op2
=
calc
.
to_number
(
sys
.
argv
[
3
])
calc
ulator
=
Calculadora
()
print
(
do_operation
(
calc
ulator
,
operation
,
op1
,
op2
))
calc
=
Calculadora
()
print
(
do_operation
(
calc
,
operation
,
op1
,
op2
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment