使用Python的列表来存储同学的身高数据,并使用循环和条件判断来进行统计。\n\npython\n# 存储同学的身高数据\nheights = []\nfor i in range(10):\n height = float(input("请输入第{}个同学的身高(单位:米):".format(i+1)))\n heights.append(height)\n\n# 统计高于1.70m和低于1.70m的人数\ncount_high = 0\ncount_low = 0\nfor height in heights:\n if height > 1.70:\n count_high += 1\n elif height < 1.70:\n count_low += 1\n\n# 输出统计结果\nprint("高于1.70m的人数:", count_high)\nprint("低于1.70m的人数:", count_low)\n\n\n这段代码会依次让你输入10个同学的身高,然后统计高于1.70m和低于1.70m的人数,并将结果输出。


原文地址: https://www.cveoy.top/t/topic/pntv 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录