判断下列程序输出的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')
- 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
- 下列程序的输出结果是___________。 x = 1 def fun: global x x = 2 fun print(x)
- def f1 (a, b): global x,y x,y=b, a return a,b x,y=10,20 print(x,y) print(f1(x,y)) print(x,y) 第二和第三个 print函数分别输出的结果是() A: (2,1) 20 10 B: (10,20) 20 10 C: (20,10) 2 1 D: (1,2) 20 10
- 以下代码执行后, num 的值是多少?var foo = function(x, y) {return x - y;};function foo(x, y) {return x + y;}var num = foo(1, 2);console.log(num);