def foo(): y = "local" foo() print(y)
举一反三
- 判断下列程序输出的x的值是?(1),y的值是(2) x = "global" def foo(): global x y = "local" x = x * 2 print(x) print(y) foo()
- Which of the following are NOT valid if/else statements in Python, assuming x and y are defined appropriately: A: if x < y: print('foo') else: print('bar') B: if x < y and x > 10: print('foo') C: if x < y: print('foo'); print('bar'); print('baz') D: if x < y: print('foo') elif y < x: print('bar') else: print('baz')
- 关于函数定义,以下形式错误的是______。 A: def foo(*a,b) B: def foo(a,*b) C: def foo(a,b) D: def foo(a,b=10)
- 关于函数定义,以下形式错误的是()。 A: def foo(a,b) B: def<br/>foo(a,b=10) C: def foo(a,*b) D: def foo(*a,b)
- 下面语句的运行结果是。 x = "foo" y = 2 print(x+y)