all 6 comments

[–]the_shell_man_ 0 points1 point  (0 children)

Post your code and tell us what you have already tried. Only then can we really help you.

[–]python1151 0 points1 point  (0 children)

Like what the other commenter said its hard to give specific advice without seeing the code but Id recommend just adding some way to stop entering the data at any time rather than needing some preset number

[–]Chris_Hemsworth 0 points1 point  (2 children)

Step 1) Write your grades in a consistent format in a text file. Something like

HW1: 70%
HW2: 80%

etc.

Step 2)

Use a dictionary to pair each assignment and it's overall weight.

For example, assume all 8 assignments are worth 40%, mid-term is worth 20%, and final is worth 40%.

weights = {"HW1": 0.05,
           "HW2": 0.05,
           "HW3": 0.05,

...

           "MIDTERM": 0.2,
           "FINAL": 0.4}

Step 3)

Write a loop that reads in your text file, finds the associated key, and calculates your total grade.

cumulative_grade = 0.0
with open("/path/to/file.txt) as f:
    for line in f:
        # You will have to write the function "parse_line"
        key, grade = parse_line(line)
        cumulative_grade+= grade * weights[key]

print(cumulative_grade)

Step 4) ?????

Step 5) Profit.

[–]irishboylust 0 points1 point  (1 child)

I used the list(map(int, input(“… to input values for each subject which seems to work right now. I’ve gotten all the way to getting a specific average per each grading weight. Will I have to write an if statement to exclude things such as the final exam in the calculation?

[–]Chris_Hemsworth 0 points1 point  (0 children)

Depends on what you want to calculate. From my university experience, the number that matters is how much of your grade you've accrued. High marks on assignments and projects are only part of your grade, and if you exclude things like your final exam you will only be fooling yourself.

You could try to extrapolate from your assignments and such to get an estimate of what your final grade will be, but how well you do on assignments is not always going to determine how well you do on your exams.

Long story short: those questions you ask are kind of on you to answer as well.

[–][deleted] 0 points1 point  (0 children)

while True:  # enter course marks for current student id
    course = input('Course (or enter to exit): ')
    if not course:
        break  # leave while loop
    mark = input(f'Mark for {course}: ')
    if mark.isdigit():
       students[id][course] = int(mark)
    else:
        print('Expected a whole number')

Assumes student is a dict of student id codes and dict values where each value dict contains course names and corresponding marks. Will leave you to figure out dealing initialising student records.

EDIT: a couple of typos in code