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
96d5a355
Commit
96d5a355
authored
Sep 29, 2015
by
muris2016
Browse files
Clase CalculadoraHija mejorada y reduccion de codigo
parent
d74cb056
Changes
1
Hide whitespace changes
Inline
Side-by-side
calcoohija.py
0 → 100644
View file @
96d5a355
#!/usr/bin/python3
# -*- coding:utf-8 -*-
import
sys
import
calc
import
calcoo
class
CalculadoraHija
(
calcoo
.
Calculadora
):
def
__init__
(
self
):
super
().
__init__
()
self
.
operations
[
"multiplica"
]
=
self
.
multiply
self
.
operations
[
"divide"
]
=
self
.
division
def
multiply
(
self
,
a
,
b
):
return
a
*
b
def
division
(
self
,
a
,
b
):
try
:
return
a
/
b
except
ZeroDivisionError
:
sys
.
exit
(
"Division by zero is not allowed"
)
if
__name__
==
"__main__"
:
op1
=
calc
.
to_number
(
sys
.
argv
[
1
])
operation
=
sys
.
argv
[
2
]
op2
=
calc
.
to_number
(
sys
.
argv
[
3
])
calculator
=
CalculadoraHija
()
print
(
calcoo
.
do_operation
(
calculator
,
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