单选题:执行以下代码并输入75和-5之后,输出结果是什么?
执行以下代码并输入75和-5之后,输出结果是什么?
def main():
try:
total = int(input("Enter total cost of items? "))
num_items = int(input("Number of items "))
average = total / num_items
except ZeroDivisionError:
print('ERROR: cannot have 0 items')
except ValueError:
print('ERROR: number of items cannot be negative')
main()
@[D](2)
A. ERROR: cannot have 0 items
B. ERROR: cannot have 0 items
ERROR: number of items can't be negative
C. ERROR: number of items can't be negative
D. 无显示内容。无print语句显示average变量。ValueError无法捕捉错误。
A.ERROR: cannot have 0 items
B.ERROR: cannot have 0 items
ERROR: number of items can't be negative
C.ERROR: number of items can't be negative
D.无显示内容。无print语句显示average变量。ValueError无法捕捉错误。
答案:D
def main():
try:
total = int(input("Enter total cost of items? "))
num_items = int(input("Number of items "))
average = total / num_items
except ZeroDivisionError:
print('ERROR: cannot have 0 items')
except ValueError:
print('ERROR: number of items cannot be negative')
main()
@[D](2)
A. ERROR: cannot have 0 items
B. ERROR: cannot have 0 items
ERROR: number of items can't be negative
C. ERROR: number of items can't be negative
D. 无显示内容。无print语句显示average变量。ValueError无法捕捉错误。
A.ERROR: cannot have 0 items
B.ERROR: cannot have 0 items
ERROR: number of items can't be negative
C.ERROR: number of items can't be negative
D.无显示内容。无print语句显示average变量。ValueError无法捕捉错误。
答案:D