我需要帮助来创建一个可以计算GPA的python程序

时间:2017-10-26 04:09:31

标签: python calculator

创建一个需要GPA为5个类的python程序。它必须是:2-3学分89和70,2-2学分94和80,1-4学分95。 我想出了这个,但还没有走得太远。:

   def name():
    name = input ("Enter a student name ")
    Grade1 = input ("Enter a grade: ")
    Grade2= input ("Enter a grade: ")
    Grade3 = input ("Enter a grade: ")
    Grade4 = input ("Enter a grade: ")
    Grade5 = input ("Enter a grade: ")
    return name, Grade1, Grade2, Grade3, Grade4, Grade5

def Grades(Grade1, Grade2, Grade3, Grade4, Grade5):
        if (Grade1, Grade2, Grade3, Grade4, Grade5) == '2 credits' or (Grade1, Grade2, Grade3, Grade4, Grade5) == '3 credits'
            (G1, G2, G3, G4, G5)= 89 and 90
        elif (Grade1, Grade2, Grade3, Grade4, Grade5) == '2 credits' or (Grade1, Grade2, Grade3, Grade4, Grade5)=='2 credits'
            (G1, G2, G3, G4, G5)= 94 and 80
        elif (Grade1, Grade2, Grade3, Grade4, Grade5)== '1 credit' or (Grade1, Grade2, Grade3, Grade4, Grade5)== '4 credits'
            (G1, G2, G3, G4, G5)= 95
        else:
            return 'invalid grade'
        return G1,G2,G3,G4,G5

def GPA(G1,G2,G3,G4,G5):
    GPA = (G1,G2,G3,G4,G5)/5
    return GPA
def main(name, GPA):
    print "The GPA for", name, "is", GPA
    return 0

Name()=name,Grade1,Grade2,Grade3,Grade4,Grade5
Grades(Grade1,Grade2,Grade3,Grade4,Grade5)=G1,G2,G3,G4,G5
GPA(G1,G2,G3,G4,G5)=GPA
main(name,GPA)=0

0 个答案:

没有答案