用python语言循环结构程序编写一个学生成绩转换程序用户输入百分制的学生成绩:90~100时输出为A80~89时输出为B70~79时输出为C60~69时输出为D0~59时输出为E。输入数据超过100时输出data error!。用户可反复输入成绩进行转换输入负数时输出end并结束程序。
while True: score = float(input("请输入成绩:")) if score < 0: print("end") break elif score > 100: print("data error!") continue elif score >= 90: print("A") elif score >= 80: print("B") elif score >= 70: print("C") elif score >= 60: print("D") else: print("E")
原文地址: https://www.cveoy.top/t/topic/hm4o 著作权归作者所有。请勿转载和采集!