网络知识 娱乐 「Python条件结构」if…elif…else成绩等级信息

「Python条件结构」if…elif…else成绩等级信息

{"data":{"title":"「Python条件结构」if…elif…else成绩等级信息","abstract":"功能要求由计算机对学生的成绩进行分级(补考、及格、中、良、优),其划分标准为:小于60为补考;60~70分为及格;70~80分为中;80~90分为良;90~100分为优。最终输出等级信息。","cover":"https://p3.toutiaoimg.com/origin/tos-cn-i-qvj2lq49k0/20a3fd82ebdd4253b2a1e72b0560b2b4","articleType":"article","itemId":"7112411566066188835","groupId":"7112411566066188835","groupSource":2,"isOriginal":true,"banComment":false,"publishTime":"2022-06-23 20:29","source":"夜晚回家","tag":"","mediaSite":null,"pathname":"/article/7112411566066188835/","loginUserInfo":null,"favorite":false,"relation":{"isFollowing":false,"isFollowed":false},"likeData":{"userLikeStatus":0,"count":8},"isSelf":false,"content":"

功能要求

由计算机对学生的成绩进行分级(补考、及格、中、良、优),其划分标准为:小于60为补考;60~70分为及格;70~80分为中;80~90分为良;90~100分为优。最终输出等级信息。

从键盘上输入学生的成就,当学生的成就在0~100之间时,在对成绩等级进行判断,如果成绩不在0~100之间给出“无效的成绩”提示。

实例代码

score = eval(input('请输入你的成绩(0~100):')) # 输入学生成绩

if score < 0 or score > 100: # 判断成绩是否大于100,或小于0,即无效成绩

print('无效的成绩')

elif score < 60: # 小于60分,不及格

print('不及格')

elif score < 70: # 大于等于60,且小于70,及格

print('及格')

elif score < 80: # 大于等于70,且小于80,中等

print('中等')

elif score < 90: # 大于等于80,且小于90,良好

print('良好')

else: # 所有条件都不满足,即成绩大于等于90,且小于等于100,优秀

print('优秀')

运行结果

从键盘上输入“158”,则score = 158,score > 100,不是正确的成绩,输出“无效的成绩”。

「Python条件结构」if…elif…else成绩等级信息

从键盘上输入“48”,则score = 48,0 <= score < 60,输出“不及格”。

「Python条件结构」if…elif…else成绩等级信息

从键盘上输入“68”,则score = 68,60 <= score < 70,输出“及格”。

「Python条件结构」if…elif…else成绩等级信息

从键盘上输入“78”,则score = 78,70 <= score < 80,输出“中等”。

「Python条件结构」if…elif…else成绩等级信息

从键盘上输入“88”,则score = 88,70 <= score < 80,输出“良好”。

「Python条件结构」if…elif…else成绩等级信息

从键盘上输入“98”,则score = 98,90 <= score <= 100,输出“优秀”。

「Python条件结构」if…elif…else成绩等级信息

","imageList":["https://p9.toutiaoimg.com/origin/tos-cn-i-qvj2lq49k0/076e8da988a04fe4ba0dfd6dbb9a732f?from=pc","https://p9.toutiaoimg.com/origin/tos-cn-i-qvj2lq49k0/e87f07f4d3fb4b70a1c6dd47d1938b5b?from=pc","https://p9.toutiaoimg.com/origin/tos-cn-i-qvj2lq49k0/54d7b9377eed4193b8a1de4cf9dab0a8?from=pc","https://p9.toutiaoimg.com/origin/tos-cn-i-qvj2lq49k0/0b72127026fc44f98155dc0c1ee57f5f?from=pc","https://p9.toutiaoimg.com/origin/tos-cn-i-qvj2lq49k0/51ef2570309d41168dd2132a2b1c457b?from=pc","https://p9.toutiaoimg.com/origin/tos-cn-i-qvj2lq49k0/940639c55f524a86a7c03584762a692f?from=pc"],"mediaInfo":{"userId":"MS4wLjABAAAAEOHatHqme6qMSxPFpzgvKWnHCePUo-PRhygTsNZ8Xdg","unsafeUserId":"106024525194","name":"夜晚回家","avatarUrl":"https://p3.toutiaoimg.com/origin/tos-cn-i-jcdsk5yqko/c7a6a11d70464518984d257ab71a6bc3","description":"学习中的笔记,授课时的教案、任务书","userVerified":1,"userAuthInfo":""},"seoTDK":{"title":"「Python条件结构」if…elif…else成绩等级信息-今日头条","description":"功能要求由计算机对学生的成绩进行分级(补考、及格、中、良、优),其划分标准为:小于60为补考;60~70分为及格;70~80分为中;80~90分","keywords":"Python,电脑","publishTimestamp":"1655987374","modifiedTimestamp":"1656000577"},"logId":"202206241340460101502112070C990C75","sylpageConfig":{"card":{"id":""}},"identity":{"web_id":"7111199547455817229","user_is_login":false},"abtestInfo":{"rsp_type":5,"version_name":"4252807,4164637","parameters":{"feat_repost_type":{"new":true},"home_nav_conf":{"dcd_out":1},"local_filter":{"core_filter":{"filter_list":{"ms::TicaiFilter":true}}},"page_upgrade":{"new_profile":true,"video_double_column":true},"sati":{"enable_ad_prime":true,"enable_sorter_optimus":true,"prime_rule_rank_version":"toutiao_web","use_toutiao_web_feed":true,"format_max_consecutive_middle":2,"format_max_consecutive_nogroups":3,"enable_reduce_nogroup":true},"seraph":{"score_rule":{"default":{"replace":{"group_util":"_CTR - 1000*dislike"}},"new_user":{"replace":{"group_util":"_CTR - 1000*dislike"}}}},"sort":{"allowed_ticai":["forum_post","pgc_text","pgc_video"]},"video_detail_page_upgrade":{"new_page":true}},"env_flag":0},"localCityInfo":{"name":"北京","code":"110000","channelId":3202164529},"showResearch":false}}