メインコンテンツへスキップ
ぴよパスぴよパス

Python 3 エンジニア認定基礎試験 エラーと例外・クラス 練習問題 第3問: 次のコードを実行したときの出力はどれか。

エラーと例外・クラス
– / 18 解いた
第3問

次のコードを実行したときの出力はどれか。

def tally():
    total = 0
    last = 0
    def add(n):
        nonlocal total
        total += n
        last = n
    add(1)
    add(2)
    return [total, last]

print(tally())
解答と解説を先に見る

先に見ると、この問題は今回は育ちません。

やめる(試験トップへ戻る)
広告
広告