def main(args):
num, den = args
try:
num, den = float(num), float(den)
except ValueError as e:
logging.error('Invalid input')
return INVALID_INPUT
if den == 0:
# this is a run-time error but not a type error
# can be considered a warning or an error based on use case
# written here as mere warning.
logging.warn('Invalid denominator input!')
return DIV_BY_ZERO_EXIT
if math.isnan(num) or math.isnan(den):
return INVALID_INPUT_NAN
if math.isinf(num) or math.isinf(den):
return INVALID_INPUT_INF
print('Answer: ' + str(num / den))
return 0
div_all_conditions_sol.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录