如何确定一些变量的优先级

时间:2019-03-29 01:57:20

标签: python

好的,所以我一直遇到一个问题,那就是将变量的优先级与长度无关。我希望优先考虑卓越学分,因为这是他在NCEA中获得最高价值的学分,然后我希望优先对功绩进行优先考核,直到获得最佳80学分为止。

到目前为止,我仅看到有关使用max()的示例,这不是我所需要的

    #Ncea Calculator
EXCELLENCE_THRESHOLD = 50
MERIT_THRESHOLD = 50

user_input_achieved = input("How many NCEA acheived credits do you have: ")
total_achieved_credits = int(user_input_achieved)

user_input_merit = input("How many NCEA merit credits do you have: ")
total_merit_credits = int(user_input_merit)

user_input_excellence = input("How many NCEA excellence credits do you have: ")
total_excellence_credits = int(user_input_excellence)

excellence_endorsement_applies = False
if total_excellence_credits >= EXCELLENCE_THRESHOLD:
   excellence_endorsement_applies = True

merit_endorsement_applies = False
if total_merit_credits + total_excellence_credits >= MERIT_THRESHOLD:
   merit_endorsement_applies = True

print('You have a total of', total_achieved_credits + total_merit_credits + total_excellence_credits ,'NCEA credits')

if excellence_endorsement_applies == True:
   print("You also got an overall excellence endorsment, well done!")

if merit_endorsement_applies == True and excellence_endorsement_applies == False:
   print("You got an overall merit endorsment, well done but theres still room for improvement!")

total_credits_this_year = total_achieved_credits + total_merit_credits + total_excellence_credits

if total_credits_this_year >= int(80):
   print("You passed Ncea Level 1!")

if total_credits_this_year < int(79):
   print("You failed Ncea Level 1, come on man!")

rank_score_achieved = int(user_input_achieved) * int(2)
rank_score_merit = int(user_input_merit) * int(3)
rank_score_excellence = int(user_input_excellence) * int(4)

total_rank_score = rank_score_achieved + rank_score_merit + rank_score_excellence

print ('your total rank score is', total_rank_score)

因此,如果用户写了: 获得多少学分:20 功绩学分:30 多少个卓越学分:50

那么我希望它选出最好的80个,以便它选出50个卓越,然后选30个功绩学分,然后计算排名得分。

0 个答案:

没有答案