import mathn=input("Enter:")try : n = float(n) print(math.sqrt(n)) print("done")except Exception as abc: print("出错了") print(abc)print("End")运行以上程序,如果输入n为4,则结果为:
A: 出错了could not convert string to float: '12a'End
B: 出错了End
C: 出错了math domain errorEnd
D: 2.0doneEnd
A: 出错了could not convert string to float: '12a'End
B: 出错了End
C: 出错了math domain errorEnd
D: 2.0doneEnd
举一反三
- 下面程序的输出结果是( )。 n = 1 while n < 6: if n == 3: print(" ",end=' ') else: print(n,end=' ') n = n + 1
- 阅读下面的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=’’)
- 运行如下程序,输出结果是 。 try: x, y = 1, 0 z = x / y print(0, end=",") except: print("1", end=",") else: print("2", end=",") finally: print("3", end=",")
- 以下程序的运行结果为:a=15if a>15: print(5,end="")if a>10: print(20,end="")if a>5: print(35,end="")
- 下面可以输出浮点数3.0的程序语句有: A: print(float('3.0')) B: print(float(3)) C: print(float(' 3.0\n')) D: print(float('\t 3.0\n'))