0

I am a very beginning programmer, and I am trying to create a grade book program for a professor at a university, so that he may input his midterm and final exam scores and get an average and letter grade for each student per course. The program is supposed to get input for the Course Number, Course Level, Number of Exams, and Student info (ID and exam scores).

At first I was thinking to create a dictionary with the ID as the key and the average as the value, but then that just didn't seem to work, so I started to try and create while loops with conditional.

Basically the code is a mess, and I am not exactly sure what I am doing wrong. I have watched tutorials and read a ton of things online, but I'm hitting a brick wall with this. For one thing I keep getting an Invalid Syntax error on line 22 with the elif statement. Any help anyone can give with this would be really appreciated! Apologies in advance for anything I am leaving out here - I am new to all this.

Thank you!

print("Hello! Welcome to your Grading Program!\n")
courseCode = input("Please enter the course code : ")
courseLevel = input("Please enter the course level : ")
numberExams = float(input("Please enter the number of exams : "))
enterStudents = input("Would you like to input a student, Yes or No? : ")

student = 0

while enterStudents == "Yes" or "yes" or "y" or "Y" :
    if courseLevel == "undergrad" or "Undergrad" or "undergraduate" or "u" or "U":
        for student in range(int(numberExams)):
            ID = input("Please enter student ID: ")
            midterm = int(float(input("Please enter midterm score: ")))
            finalExam = int(float(input("Please enter final exam score: ")))
            undAverage = (midterm * .60) + (finalExam * .40)
    elif courseLevel == "grad" or "Grad" or "Graduate" or "g" or "G":
        for student in range(int(numberExams)):
            ID = input("Please enter student ID: ")
            midterm = int(float(input("Please enter midterm score: ")))
            finalExam = int(float(input("Please enter final exam score: ")))
            undAverage = (midterm * .30) + (finalExam * .70)               
elif enterStudents == "No" or "no" or "n" or "N" :
    print("\nSee you next time!")
else:
    enterStudents == "" :
        input("Invalid Entry! Would you like to input a student, Yes or No?:")

def Grade():
    for letter in Grade:
        total = 100
    for letter in Grade(A,B,C,D,E,F):
        if undGrade == "A":
                    undAverage >= range(85,101)
        elif undGrade == "B":
                    undAverage >= range(70,85)
        elif undGrade == "C":
                    undAverage >= range(55,70)
        elif undGrade == "D":
                    undAverage >= range(40,55)
        elif undGrade == "F":
                    undAverage >= range(0,40)
    print(Grade)

1 Answers1

0

Your or statements should be 'complete'.

elif courseLevel == "grad" or "Grad" or "Graduate" or "g" or "G":

Needs to become:

elif courseLevel == "grad" or courseLevel == "Grad" or courseLevel == "Graduate" or courseLevel == "g" or courseLevel == "G":

Easier would be to do it like:

elif courseLevel.lower() in ['grad', 'graduate', 'g']:

.lower(): to cater to ignore case sensitive words

in []: to look for the item in an list/array

Furthermore (credits to @Ashwini), a while-elif combination does not exist.

RvdK
  • 19,580
  • 4
  • 64
  • 107
  • Main issue is the while-elif condition, OP's code isn't even compiling in the first place. – Ashwini Chaudhary Oct 13 '14 at 11:43
  • I will change that - I knew there had to be a better way to do that. Thank you! – flamingjune5dwj Oct 13 '14 at 11:45
  • @AshwiniChaudhary -- Yes, I haven't been able to get it to loop through the number of tests entered per course correctly. It seems it just loops infinitely, asking me to enter students and grades endlessly. I am not understanding the structure there or something properly. – flamingjune5dwj Oct 13 '14 at 11:47
  • Ah indeed, there is also the other issue. while elif is indeed not valid. – RvdK Oct 13 '14 at 13:51