设计多层决策系统来确定奖学金的资格标准
偷偷努力,悄无声息地变强,然后惊艳所有人!哈哈,小伙伴们又来学习啦~今天我将给大家介绍《设计多层决策系统来确定奖学金的资格标准》,这篇文章主要会讲到等等知识点,不知道大家对其都有多少了解,下面我们就一起来看一吧!当然,非常希望大家能多多评论,给出合理的建议,我们一起学习,一起进步!

问题
使用 if-else 语句设计一个多层决策系统,可用于确定奖学金的资格标准。该系统应考虑多种因素,例如成绩、课外活动和财务需求。
思考过程
要设计一个多层决策系统来根据成绩、课外活动和财务需求确定奖学金资格,您需要一种结构化的方法来评估和分配奖学金金额。以下是如何使用 if-else 语句创建决策系统的逐步细分:
奖学金决定标准
- 财务状况:确定学生的经济困难程度。
- 课外活动:衡量学术之外的参与程度。
- 成绩:反映学业表现。
奖学金决定逻辑
- 确定财务需求:检查学生是否属于高、中或低财务需求类别。
- 评估课外活动参与情况:在每个财务需求类别中,检查学生在课外活动中的活跃程度。
- 评估成绩:最后评估学生的成绩,以决定确切的奖学金金额。
奖学金金额
- 高需求,高课外活动,高成绩:最高奖学金。
- 高需求,中等课外活动,中等成绩:中等奖学金。
- 高需求,低课外活动,低成绩:奖学金很少。
- 中等需求,高课外活动,高成绩:大量奖学金。
- 中等需要,中等课外活动,中等成绩:中等奖学金。
- 中等需求,低课外活动,低成绩:最低奖学金。
- 低需求,高课外活动,高成绩:中等奖学金。
- 低需求,中等课外活动,中等成绩:小额奖学金。
- 低需求,低课外活动,低成绩:无奖学金。
解决方案
def scholarship(financial_cond, extra_act, grades):
if financial_cond >=80:
if extra_act >=80:
if grades >=80:
return 5000
if grades>= 60 and grades <80:
return 3000
if grades>= 40 and grades <60:
return 2000
if extra_act >= 60 and extra_act < 80:
if grades >=80:
return 4000
if grades>= 60 and grades <80:
return 2000
if grades>= 40 and grades <60:
return 1000
if extra_act >= 40 and extra_act <60:
if grades >=80:
return 3000
if grades>= 60 and grades <80:
return 1000
if grades>= 40 and grades <60:
return 000
if financial_cond >=60 and financial_cond <80:
if extra_act >=80:
if grades >=80:
return 4000
if grades>= 60 and grades <80:
return 2000
if grades>= 40 and grades <60:
return 1000
if extra_act >= 60 and extra_act < 80:
if grades >=80:
return 3000
if grades>= 60 and grades <80:
return 1000
if grades>= 40 and grades <60:
return 0000
if extra_act >= 40 and extra_act <60:
if grades >=80:
return 2000
if grades>= 60 and grades <80:
return 0000
if grades>= 40 and grades <60:
return 000
if financial_cond >= 40 and financial_cond <60:
if extra_act >=80:
if grades >=80:
return 3000
if grades>= 60 and grades <80:
return 1000
if grades>= 40 and grades <60:
return 000
if extra_act >= 60 and extra_act < 80:
if grades >=80:
return 2000
if grades>= 60 and grades <80:
return 000
if grades>= 40 and grades <60:
return 000
if extra_act >= 40 and extra_act <60:
if grades >=80:
return 1000
if grades>= 60 and grades <80:
return 000
if grades>= 40 and grades <60:
return 000
else:
return 0
financial_cond = float(input('enter financial condition in 1 to 100 '))
extrac_act = float(input('enter the extracurricular participation in 1 to 100 '))
grades= float(input('enter the grades of the student '))
print(scholarship(financial_cond, extrac_act, grades))
其他想法
1
financial_cond = float(input('enter financial condition in 1 to 100 '))
extrac_act = float(input('enter the extracurricular participation in 1 to 100 '))
grades= float(input('enter the grades of the student '))
def scholarship():
if financial_cond >= 80 and extrac_act >= 80 and grades >= 80:
return 10000
elif financial_cond >= 80 and extrac_act >= 80 and grades >= 60 and grades <80:
return 5000
elif financial_cond >= 80 and extrac_act >= 80 and grades >= 40 and grades < 60:
return 2000
elif financial_cond >= 80 and extrac_act >= 60 and extrac_act < 80 and grades >= 80:
return 5000
elif financial_cond >=80 and extrac_act >=60 and extrac_act < 80 and grades >= 60 and grades < 80:
return 2000
elif financial_cond >= 80 and extrac_act >=50 and extrac_act < 60 and grades >= 60 and grades < 80:
return 1000
elif financial_cond >= 60 and financial_cond < 80 and extrac_act >= 80 and grades >=80:
return 5000
elif financial_cond >=60 and financial_cond < 80 and extrac_act >=60 and extrac_act < 80 and grades >= 80:
return 2000
elif financial_cond >=60 and financial_cond < 80 and extrac_act >= 60 and extrac_act < 80 and grades >= 60 and grades < 80:
return 1000
else:
return 0
scholarship()
拒绝原因:
- 范围和冗余:scholarship()函数不带参数,因此它依赖于直接输入的全局变量(financial_cond、extrac_act、grades)。这种设计模块化程度较低,可能会导致代码维护和测试方面出现问题。
- 重叠和歧义:某些条件重叠或冗余。例如,多个 elif 分支检查相似的条件,但阈值或范围略有不同,这可能会使逻辑混乱且容易出错。
- 逻辑复杂性:使用具有重叠条件的多个 elif 语句会产生难以理解的复杂结构。目前尚不清楚哪种情况为真以及在各种情况下最终结果会是什么。
2
def scholarship(financial_cond, extra_act, grades):
if financial_cond >= 80:
return high_financial(extra_act, grades)
elif financial_cond >= 60:
return medium_financial(extra_act, grades)
elif financial_cond >= 40:
return low_financial(extra_act, grades)
else:
return 0
def high_financial(extra_act, grades):
if extra_act >= 80:
if grades >= 80:
return 5000
elif grades >= 60:
return 3000
elif grades >= 40:
return 2000
elif extra_act >= 60:
if grades >= 80:
return 4000
elif grades >= 60:
return 2000
elif grades >= 40:
return 1000
elif extra_act >= 40:
if grades >= 80:
return 3000
elif grades >= 60:
return 1000
elif grades >= 40:
return 0
def medium_financial(extra_act, grades):
if extra_act >= 80:
if grades >= 80:
return 4000
elif grades >= 60:
return 2000
elif grades >= 40:
return 1000
elif extra_act >= 60:
if grades >= 80:
return 3000
elif grades >= 60:
return 1000
elif grades >= 40:
return 0
elif extra_act >= 40:
if grades >= 80:
return 2000
elif grades >= 60:
return 0
elif grades >= 40:
return 0
def low_financial(extra_act, grades):
if extra_act >= 80:
if grades >= 80:
return 3000
elif grades >= 60:
return 1000
elif grades >= 40:
return 0
elif extra_act >= 60:
if grades >= 80:
return 2000
elif grades >= 60:
return 0
elif grades >= 40:
return 0
elif extra_act >= 40:
if grades >= 80:
return 1000
elif grades >= 60:
return 0
elif grades >= 40:
return 0
financial_cond = float(input('enter financial condition in 1 to 100: '))
extra_act = float(input('enter the extracurricular participation in 1 to 100: '))
grades = float(input('enter the grades of the student: '))
print(scholarship(financial_cond, extra_act, grades))
拒绝原因:
- 代码冗余:确定奖学金的逻辑在不同的财务需求类别(high_financial、medium_financial、low_financial)中重复,导致代码冗余。这可以简化以避免重复并降低不一致的风险。
- 函数调用的复杂性:嵌套的函数调用和多层条件使代码更难以遵循和维护。分离成不同的函数有利于模块化,但由于嵌套条件的数量可能会过多且令人困惑。
- 奖学金金额不一致:不同经济需求水平之间的奖学金金额决定逻辑并不总是一致,这可能会导致人们对为什么要根据特定条件给予某些奖学金金额产生潜在的困惑。
3
grades = float(input("enter the applicant's gpa : "))
extracurriculars = int(input("enter the number of extracurricular activities: "))
financial_need = input("is there a financial need? (yes/no): ").strip().lower()
eligible = true
grade_thresholds = [3.5, 3.0, 2.5]
scholarship_level = none
for threshold in grade_thresholds:
if grades >= threshold:
if threshold == 3.5:
scholarship_level = "full scholarship"
elif threshold == 3.0:
scholarship_level = "partial scholarship"
elif threshold == 2.5:
scholarship_level = "basic scholarship"
break
else:
eligible = false
print("applicant does not meet the minimum grade requirement.")
if eligible:
extracurricular_threshold = 2 # minimum number of activities required
if extracurriculars < extracurricular_threshold:
eligible = false
print("applicant does not meet the extracurricular activities requirement.")
if eligible:
while financial_need not in ['yes', 'no']:
financial_need = input("please enter 'yes' or 'no' for financial need: ").strip().lower()
if financial_need == 'no':
scholarship_level = "merit-based scholarship" # adjust the scholarship type based on no financial need
if eligible:
print(f"the applicant is eligible for the {scholarship_level}.")
else:
print("the applicant is not eligible for the scholarship.")
拒绝原因
- 过于简单化:该方法过于简单化,因为它没有考虑一系列条件,而是使用单一的成绩阈值和财务需求的二进制检查。这可能会忽略确定资格和奖学金金额时的重要细微差别。
- 硬编码值:奖学金级别是根据 gpa 和财务需求的二进制检查进行硬编码的,而不考虑其他因素,例如课外参与程度或更细粒度的财务需求评估。
- 交互处理:如果用户不输入“是”或“否”,处理财务需求输入的循环可能会导致无限循环(尽管无限循环在实践中可能是一个罕见的问题,但它是一个潜在的缺陷)。
选择解决方案的原因及其潜在缺陷
让我们回顾一下所提出的解决方案并分析其选择的原因以及潜在的缺陷:
建议的解决方案
def scholarship(financial_cond, extra_act, grades):
if financial_cond >=80:
if extra_act >=80:
if grades >=80:
return 5000
elif grades >= 60:
return 3000
elif grades >= 40:
return 2000
elif extra_act >= 60:
if grades >=80:
return 4000
elif grades >= 60:
return 2000
elif grades >= 40:
return 1000
elif extra_act >= 40:
if grades >=80:
return 3000
elif grades >= 60:
return 1000
elif grades >= 40:
return 0
elif financial_cond >=60:
if extra_act >=80:
if grades >=80:
return 4000
elif grades >= 60:
return 2000
elif grades >= 40:
return 1000
elif extra_act >= 60:
if grades >=80:
return 3000
elif grades >= 60:
return 1000
elif grades >= 40:
return 0
elif extra_act >= 40:
if grades >=80:
return 2000
elif grades >= 60:
return 0
elif grades >= 40:
return 0
elif financial_cond >= 40:
if extra_act >=80:
if grades >=80:
return 3000
elif grades >= 60:
return 1000
elif grades >= 40:
return 0
elif extra_act >= 60:
if grades >=80:
return 2000
elif grades >= 60:
return 0
elif grades >= 40:
return 0
elif extra_act >= 40:
if grades >=80:
return 1000
elif grades >= 60:
return 0
elif grades >= 40:
return 0
else:
return 0
financial_cond = float(input('Enter financial condition in 1 to 100 '))
extra_act = float(input('Enter the extracurricular participation in 1 to 100 '))
grades = float(input('Enter the grades of the student '))
print(scholarship(financial_cond, extra_act, grades))
选择理由
结构化方法:该解决方案采用多层决策流程,系统地评估财务状况、课外活动和成绩。这种结构化方法可以采用清晰、有组织的方法来确定奖学金资格。
详细评估:该解决方案涵盖了一系列具有特定阈值的条件,包括经济需求、课外活动和学业成绩,为分配奖学金金额提供了详细的框架。
模块化:通过分离不同级别的财务需求并评估这些级别内的其他标准,该解决方案引入了更易于管理和更新的模块化结构。
清晰的决策路径:嵌套的 if-else 语句创建了清晰的决策路径,明确了哪些条件导致了哪些奖学金金额。
潜在缺陷
冗余和复杂性:代码包含大量冗余。例如,对成绩和课外活动的检查会重复多次。这种冗余增加了代码的复杂性,并使其更难以维护和理解。
代码重复:每个范围的financial_cond的决策逻辑都有相似的模式,但阈值略有不同。可以通过整合通用逻辑并减少重复的代码块来避免这种重复。
硬编码值:奖学金金额和阈值是硬编码的,这使得它不灵活。如果需要更改标准或金额,则必须手动更新代码。使用配置文件或常量可以提高灵活性。
缺乏输入验证:代码不会验证输入以确保它们在预期的范围或类型内。例如,financial_cond、extra_act 和grades 预计在 1 到 100 之间,但代码不会强制或验证这一点。
边缘情况:该解决方案不能稳健地处理边缘情况。例如,如果 financial_cond、extra_act 或 grades 正好位于边界值上(例如,正好 40、60 或 80),则处理有些不明确。更清晰地处理边界情况将使决策逻辑更精确。
没有反馈或解释:该解决方案仅提供奖学金金额,并没有解释为什么给予一定金额。添加反馈或解释可以提高用户理解和透明度。
您能根据现代标准改进建议的解决方案吗? [提示:重构冗余、实现输入验证、使用常量并增强用户反馈]
高级解决方案:https://insightshub.in/design-a-multi-tier-decision-making-system-to-define-the-eligibility-criteria-for-a-scholarship/#h-advanced-solution
今天关于《设计多层决策系统来确定奖学金的资格标准》的内容介绍就到此结束,如果有什么疑问或者建议,可以在golang学习网公众号下多多回复交流;文中若有不正之处,也希望回复留言以告知!
移动应用程序物联网对移动应用程序开发的影响
- 上一篇
- 移动应用程序物联网对移动应用程序开发的影响
- 下一篇
- 设计多层决策系统来确定奖学金的资格标准
-
- 文章 · python教程 | 11小时前 | logging · Python教程 · 后端开发 · 日志排查 · Python logging 日志重复 propagate addHandler basicConfig
- Python logging 日志重复打印排查:为什么一条记录输出了两遍
- 324浏览 收藏
-
- 文章 · python教程 | 1星期前 | 默认值 · python · 数据建模 · dataclass · default_factory · field · Python 数据类 Field 可变默认值 dataclass default_factory
- Python dataclass 默认值完整工作流:从可变默认值到 default_factory
- 228浏览 收藏
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 543次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 516次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 500次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 485次学习
-
- ljg-skills
- ljg-skills 是李继刚开源的 AI 技能与提示词集合,面向大模型使用者整理了一批可复用的 prompt、角色设定和任务技能模板,适合用于学习提示词设计、搭建个人 AI 工作流和沉淀团队常用智能体能力。
- 2567次使用
-
- MELO音乐
- MELO音乐是一站式AI视频与音乐制作助手,对标suno, udio的高品质体验。提供伴奏生成、原创写词、无损导出、哼唱识曲、混音变声等全套音频与短视频编辑工具。无论是流行Kpop、电音说唱、民谣古风、摇滚儿歌还是商用轻音乐,MELO为你免费谱曲,轻松做同款!
- 2376次使用
-
- UniScribe
- UniScribe 是一款 AI 音视频转文字与内容整理工具,支持上传音频、视频文件或粘贴 YouTube 链接,自动生成转写文本、摘要、思维导图和关键问题,并支持多格式导出,适合会议记录、课程学习、访谈整理和内容创作复盘。
- 2316次使用
-
- 剧云
- 剧云是专业中文剧本创作平台,安全稳定运行十余年,集成AI编剧、剧本医生审核、人物小传、剧情关系图、大纲编写、多人协作、Word导入导出、版权管控功能,数据安全防护,轻松高效创作剧本。
- 2527次使用
-
- 万象有声
- 万象有声,一个专为有声创作者打造的新一代智能有声内容创作平台。平台提供专业的智能拆章、智能画本编辑、AI配音、AI生成音效、后期制作、智能对轨、智能审听等有声创作全流程工具,可以帮助创作者高效、低成本创作出引人入胜的有声作品。立即体验,让有声书制作更简单!
- 2505次使用
-
- Python监控网页状态:requests异常处理实战
- 2026-05-29 501浏览
-
- TensorFlow模型部署为API的TF Serving方法
- 2026-05-26 501浏览
-
- Python字符串编码转换:encode与decode详解
- 2026-05-16 501浏览
-
- TensorFlow裁剪无用算子方法详解
- 2026-05-15 501浏览
-
- httpx 如何设置代理认证(Proxy-Authorization)
- 2026-05-05 501浏览

