fork(1) download
  1.  
  2. class Cuenta:
  3. def __init__(self, saldo_inicial=0):
  4. self.saldo = saldo_inicial
  5.  
  6. def ingresa(self, cantidad):
  7. cantidad = abs(cantidad)
  8. self.saldo += cantidad
  9.  
  10. def retira(self, cantidad):
  11. cantidad = abs(cantidad)
  12. self.saldo -= cantidad
  13.  
  14. def __str__(self):
  15. return str(self.saldo)
  16.  
  17.  
  18.  
  19. if __name__ == "__main__":
  20. c1 = Cuenta()
  21. c2 = Cuenta(1000)
  22.  
  23. c1.ingresa(400)
  24. c2.retira(70)
  25.  
  26. c2.ingresa(45)
  27. c2.retira(45)
  28.  
  29. print(c1)
  30. print(c2)
  31.  
Success #stdin #stdout 0.02s 9344KB
stdin
Standard input is empty
stdout
400
930