Skip to content

Instantly share code, notes, and snippets.

@ks7000
Created May 4, 2017 01:33
Show Gist options
  • Save ks7000/c5203118ebad53e8a704196cf61d0799 to your computer and use it in GitHub Desktop.
Save ks7000/c5203118ebad53e8a704196cf61d0799 to your computer and use it in GitHub Desktop.
Aplicación didáctica con registro de eventos por pantalla e identificado por cada módulo.
import logging
logging.basicConfig(level=logging.DEBUG)
bita_sum = logging.getLogger("Sum")
bita_res = logging.getLogger("Res")
bita_mul = logging.getLogger("Mul")
bita_div = logging.getLogger("Div")
class calculadora():
def __init__(self, nombre):
self.nombre = nombre
logging.debug("\nCalculadora modelo {} (encendida).".format(self.nombre))
def sumar(self, a=0, b=0):
bita_sum.debug("Suma a={} b={} a+b={}".format(a,b,a+b))
def restar(self, a=0, b=0):
bita_res.debug("Resta a={} b={} a-b={}".format(a,b,a-b))
def multiplicar(self, a=0, b=0):
bita_mul.debug("Multiplicación a={} b={} a*b={}".format(a,b,a*b))
def dividir(self, a=0, b=1):
bita_div.debug("División a={} b={} a/b={}".format(a,b,a/b))
calc = calculadora("A1")
calc.sumar( 12,4)
calc.restar(12,4)
calc.multiplicar(12,4)
calc.dividir(12,4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment