python语言从控制台输入一个体重0-80斤输出变81-120斤输出中等121斤以上输出肥胖其他为非法输入。要求语言提示良好。
weight = input("请输入体重(单位:斤):") try: weight = float(weight) if weight < 0 or weight > 120: print("输入的体重不合法!") elif weight <= 80: print("变成了{:.0f}斤".format(weight+81)) elif weight <= 120: print("中等") else: print("肥胖") except ValueError: print("输入的体重不合法!")
原文地址: https://www.cveoy.top/t/topic/hciH 著作权归作者所有。请勿转载和采集!