Nested Functions for Division and Even/Odd Check

  • Share this:

Code introduction


This function defines nested functions to perform division and check if an integer is even or odd.


Technology Stack : Built-in functions (try-except, /, %)

Code Type : Function

Code Difficulty : Intermediate


                
                    
def aaaa(arg1, arg2, arg3):
    def bbbb():
        try:
            return arg1 / arg2
        except ZeroDivisionError:
            return "Cannot divide by zero"

    def cccc(arg):
        if arg % 2 == 0:
            return "Even"
        else:
            return "Odd"

    return bbbb(), cccc(arg3)