下面哪个分支程序的语法和程序逻辑不正确的为:
A: if x print("x小于y")
B: if x print('x小于y')
else:
print('x大于y')
C: if x print('x小于y')
D: if x print("x小于y")
else:
print("x大于y")
A: if x
B: if x
else:
print('x大于y')
C: if x
D: if x
else:
print("x大于y")
举一反三
- 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)
- 下列条件语句中,有语法错误的两个是() A: If x>y Then Print B: If<br/>x>y Then <br/>Print C: If<br/>x>y Then<br/>print D: If x>y Then print x E: If x>y then Print x Else Print y End if
- 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)
- 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')
- 执行以下程序,下面选项描述错误的是 [br][/br]x,y = 1,2 [br][/br]while x [ 20: <br] x, y = y, x + y [br][/br] print(x) A: 输出结果包含8 B: 循环次数大于10次 C: 输出结果包含5和2 D: 循环次数小于20次