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: 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')
举一反三
- 1.以下“if-elif-else”程序正确的是() A: if x>;yprint(x)elif y>;zprint(y)print(z) B: if x>;y:print(x)elif y>;z:print(y)else:print(z) C: if x>;y:print(x)elif x>;y:print(y)else:print(z) D: if x>;yprint(x)elif y>;zprint(y)elseprint(z)
- 为程序填空 x=2 y=10 z=7 if x>y: if x>z: print('max=',____) else: print('max=',z) elif ____: print('max=',y) else: print('max=',z)
- x=100[br][/br] y=x+1 if x>=0: print(x,y) if x==0: y=x print(y) else: y=x-1 print(y)
- 判断下列程序输出的x的值是?(1),y的值是(2) x = "global" def foo(): global x y = "local" x = x * 2 print(x) print(y) foo()
- 下面哪个分支程序的语法和程序逻辑不正确的为: A: if x<y:<br> print("x小于y") B: if x<y:<br> print('x小于y')<br> else:<br> print('x大于y') C: if x<y:<br> print('x小于y') D: if x<y:<br> print("x小于y")<br> else:<br> print("x大于y")