计算机 判断题 较难 ★ 精品

作用域与 global — 计算机判断题

Python 程序设计(大学通用) 函数与代码复用 AI 三重审校通过

题目
判断:有如下 Python 代码: total = 100 def add(n): total = total + n return total add(5) 函数 add 内对全局变量 total 执行了赋值操作,且未用 global 声明,因此程序运行时会抛出 UnboundLocalError 异常。