10640.以下程序的输出结果是______。 s = 10 def run(n): global s for i in range(n): s += i return s print(s,run(5))
A: 1020
B: 2020
C: 1010
D: UnboundLocalError
A: 1020
B: 2020
C: 1010
D: UnboundLocalError
举一反三
- 以下程序的输出结果是______。 [br][/br]s = 10 [br][/br]def run(n): [br][/br] global s [br][/br] for i in range(n): [br][/br] s += i [br][/br] return s [br][/br]print(s,run(5)) A: UnboundLocalErro B: 10 10 C: 20 20 D: 10 20
- 下列函数能够求n的阶乘n!的是 A: f = lambda n: n! B: def f(n): s=1 for i in range(n): s = s * i return s C: def f(n): s=1 for i in range(n,0,-1): s = s * i return s D: def f(n): if n == 1: return 1 else: return f(n-1)*n
- 下面程序的输出结果是n=2 def multiply(x,y=10): global n return x*y*n s=multiply(10,2) print(s)
- 下面程序的输出结果是______s = 'abc' try: for i in range(3): s[i] = 'a' print(s) except: print('Error')[/i]
- 以下代码执行的输出结果是 n=2def multiply(x,y = 10): global n return x*y* ns = multiply(10,2)print(s) A: 1024 B: 40 C: 200 D: 400