[PYTHON] In-function function

def test(a, b, c):

    def plus(d, e):
        return d + e

    r1 = plus(a, b)
    r2 = plus(b, c)

    print(r1 * r2)

test(3, 4, 5)

Execution result


63

For r1, the value obtained by adding 3 and 4 to the plus function is entered. Therefore, r1 = 7 For r2, the value obtained by adding 4 and 5 to the plus function is entered. Therefore, r2 = 9

Since the test function outputs the value obtained by multiplying r1 and r2, 63 is output as the execution result.

Recommended Posts

In-function function
In-function function
python function ①
[Python] function
Recursive function
python function ②
Function review
python3x: lambda function
Python> function> Closure
[Python] Generator function
Python> function> Inner function
Duality in function
Python function decorator