0
1

More than 3 years have passed since last update.

関数内関数

Posted at
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)
実行結果
63

r1はplus関数に3,4を入れた値が入る。
よって、r1=7
r2はplus関数に4, 5を入れた値が入る。
よって、r2=9

test関数はr1とr2をかけた値を出力するので、
実行結果で63が出力される。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1