#exceptions.py n = int(input("enter first number: ")) d = int(input("enter denominator: ")) try: q = n / d print("q:",q) except ZeroDivisionError as ze: print("ze:",ze," type(ze):",type(ze)) except Exception as e: #base exception, will match every exception print("e:",e," type(e):",type(e)) #can be multiple different excepts, first that matches runs, others skipped else: #optional. runs if no exceptions happened print("else") finally: #optional. always runs. cleanup print("finally") #print("After. q:",q) #q won't exist if Exception was raised print("After")