Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # excepciones built-in
- a = input("Ingrese un numero entero: ")
- b = input("Ingrese un numero entero para divisor: ")
- try:
- c = int(a)/int(b)
- except ValueError:
- print("No ha ingresado un nro entero")
- except ZeroDivisionError:
- print("El cociente debe ser no nulo")
- else:
- print(c)
- finally:
- print("Adios...")
- # otra forma:
- a = input("Ingrese un numero entero: ")
- b = input("Ingrese un numero entero para divisor: ")
- try:
- c = int(a)/int(b)
- except (ValueError, ZeroDivisionError):
- print("Error")
- else:
- print(c)
- finally:
- print("Adios...")
- # excepciones propias
- class MiExcepcion(Exception):
- pass
Advertisement
Advertisement
Advertisement
RAW Paste Data
Copied
Advertisement