Commit 96d5a355 authored by muris2016's avatar muris2016
Browse files

Clase CalculadoraHija mejorada y reduccion de codigo

parent d74cb056
# -*- coding:utf-8 -*-
import sys
import calc
import calcoo
class CalculadoraHija(calcoo.Calculadora):
def __init__(self):
self.operations["multiplica"] = self.multiply
self.operations["divide"] = self.division
def multiply(self, a, b):
return a * b
def division(self, a, b):
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))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment