ls = [" x", "y"]def fun(a) : ls.append(a) returnfun("C")print(ls)运行以上代码结果为:
A: ['C']
B: ['x', 'y']
C: ['x', 'y', 'C']
D: ['y', 'C']
A: ['C']
B: ['x', 'y']
C: ['x', 'y', 'C']
D: ['y', 'C']
举一反三
- 定义一个函数[img=122x26]18032de32eea941.png[/img],计算x=3, y=5时函数的值。不能完成该功能的是( )。知识点:函数做参数 A: import mathdef add(f,x,y): return f(x)+f(y)print(add(lambda x: math.sin(x*x),3,5)) B: import mathdef add(f,x,y): return f(x)+f(y)def func(x): return math.sin(x**2) print(add(func,3,5)) C: import mathdef func(x): return math.sin(x**2) ls=list(map(func,[3,5]))print(sum(ls)) D: import mathdef func(x): return math.sin(x**2) ls = list(filter(func,[3,5]))print(sum(ls))
- 写出下面代码的运行结果( )def exchange(...nge(x,y)print((x,y))
- def fun(x,y): global x,y t=x x=y y=t x=0 y=1 fun(x,y) print(x,y) 结果是 1 0
- 以下函数定义中,正确的是() A: def fun(x, y) B: def fun(x, y = 3.14) C: def fun(x, *y) D: def fun(*x, y)
- 下面代码的输出结果是( ).MA = lambda x,y:(x > y) * x + (x [ y) * yMI = lambda x,y:(x ] y) * y + (x < y) * xa = 10b = 20print(MA(a,b))print(MI(a,b)) A: 20,10 B: 10,20 C: 10,10 D: 20,20