以下程序的输出结果是( )。 def fun(x): try: return x*4 except: return x print(fun(”5”))

admin2022-09-09  19

问题 以下程序的输出结果是(          )。
  def fun(x):
    try:
      return x*4
    except:   
      return x
  print(fun(”5”))

选项 A、20
B、5555
C、5
D、9

答案B

解析 fun(”5”)是将字符5赋给形参x,由于5是字符类型,不是数字类型,不能进行数值运算,因此“x*4”是把字符5连续复制4次。本题选择B选项。
转载请注明原文地址:https://kaotiyun.com/show/3Z6p777K
0

相关试题推荐
最新回复(0)