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)
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)
- 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')
- 下列程序段的输出结果是_____。 x = 10 if x > 5: y = 2 * x elif x > 3: y = 3 * x elif x > 1: y = 4 * x else: y = x print(y)
- 以下程序的输出结果是。 x = z = 1 y = -1 if x > 0: if y > 0: print('AAA') elif z > 0: print('BBB')( ) A: 'BBB' B: 'AAA' C: 程序出错 D: 无输出
- 以下程序的输出结果是_____________。x = 1 y = -1 z = 1 if x > 0: if y > 0: print('AAA') elif z > 0: print('BBB') A: 无输出 B: 'AAA' C: 'BBB' D: 程序出错