运行如下程序,输出结果是 。 try: x, y = 1, 0 z = x / y print(0, end=",") except: print("1", end=",") else: print("2", end=",") finally: print("3", end=",")
举一反三
- 设有下面的语句:Print IIf(x>0, 1, IIf(x<0,-1, 0))与此语句输出结果不同的程序段是______。 A: If x>0 Then x=1 ElseIf x<0 Then x=-1 End If Print x B: If x>0 Then Print 1 ElseIf x<0 Then Print-1 Else Print 0 End If C: Select Case x Case Is>0 Print 1 Case Is<0 Print-1 Case Else Print 0 End Select D: If x<>0 Then If x>0 Then Print 1 ElseIf x<0 Then Print-1 Else Print 0 End If
- 下列程序段执行后,输出结果是: number = 20 try: if number < 0: number = -number print(number,end=) except: print("有异常发生",end=) else: print("平安无事",end=) finally: print("我很好我可以的",end=)
- 运行以下程序输出的结果是:( )。for i in range(6):if i%2==0:continueelif i%3:print(i,end=' ')else: print('end') A: 1 B: 1 end C: 1 5 end D: 1 5
- 阅读下面的python程序,请问输出结果是什么? Print(“T”,end=’’) if not 0 else print (‘F’,end=’’) Print(“T”,end=’’)if 6 else print (‘F’,end=’’) Print(“T”,end=’’)if””else print(‘F‘,end=’’) Print(“T”,end=’’)if”abc”else print(‘F’,end=’’) Print(“T”,end=’’)if____else print (‘F’,end=’’) Print(“T”,end=’’)if(1,2)else print(‘F’,end=’’) Print(“T”,end=’’)if[ ]else print(‘F’,end=’’) Print(“T”,end=’’)if[1,2]else print(‘F’,end=’’) Print(“T”,end=’’)if{ }else print(‘F’,end=’’) Print(“T”,end=’’)if{1,2}else print(‘F’,end=’’)
- def function(x): print(x,end=‘ ’) x=4.5 y=3.4 print(y,end=’ ‘)x=2y=4function(x)print(x,end= ‘ ‘)print(y)程序结果是: A: 2 3.4 2 4 B: 2 3.4 4.5 3.4 C: 2 4 2 4 D: 4.5 3.4 2 4