FROM ME TO YOU

oh my bizarre life !!

Python勉強メモ(2) 関数

(1)に引き続きPythonの文法を確認中

docs.python.org

2020/01/06 関数の定義

C# におけるstatic classみたいなものかな?戻り値についてはあとからやるのかしら。引数なしは?docstringに日本語を使ったら駄目なのかしら。

def testcalc(n):
    """Docstring."""
    print(10 + n)

testcalc(1)
# 11

戻り値

returnで定義する

def testcalc(n):
    """Docstring."""
    return 10 + n

a = testcalc(1)
# 11