下面程序段的输出为a=1def fun(a): a=a+2 print(a) fun(a)print(a)
A: 3 1
B: 4 1
C: 11
D: 33
A: 3 1
B: 4 1
C: 11
D: 33
举一反三
- 10603.下面程序段的输出为 a=1 def fun(a): a=a+2 print(a) fun(a) print(a) A: 3 1 B: 1 1 C: 4 1 D: 3 3
- 下列程序的输出结果是___________。 x = 1 def fun: global x x = 2 fun print(x)
- 在代码后面说明变量是全局变量还是局部变量num1=1 #num1为__________(1)num2=2 #num2为__________(2)def fun(): global num1 #num1为__________(3) num1 =11 num2 = 22 #num2为__________(4) print(num1,num2)fun()print(num1,num2)
- 下列程序的输出结果是?a = [1, 2, 3]print a * 2 A: [2, 4, 6] B: [1, 2, 3, 1, 2, 3] C: [11, 22, 33] D: 程序出错
- 下列说法不正确的是( )。知识点:全局变量 A: x = 5def fun(): x = 2 x = x * 3 print(x, end=' ')fun()print(x)程序无误,输出结果为6 5 B: x = 5def fun(): global x x = 2 x = x*3 print(x, end=' ')fun()print(x)程序无误,输出结果为6 6 C: x = 5def fun(): x = x * 3 print(x ,end=' ')fun()print(x)程序无误,输出的结果为15 15 D: x = 5def fun(): print(x, end=' ')fun()print(x)程序无误,输出的结果为5 5