I'm trying to open a text file in python that holds the names of people and grades from specific tests they took. These grades are also accompanied by the test weight.
Billy Bother 20 89 30 94 50 82
Hermione Heffalump 40 93 60 97
Kurt Kidd 20 88 30 82 40 76 10 99
The first number is the weight, while the second number is the grade, and this pattern continues through the file.
To calculate the
average I need to use
((w1 * g1) + (w2 * g2) + ... + (wn * gn)) / 100, where
w = weight and
g = grade.
I have no idea how to set up the code to make this work.
Can anyone help me?
I'm assuming this is a school assignment, so I will just give an outline of how to approach it, rather than writing a solution for you.
You will need to find out how to:
You should be able to find solutions to all of these sub-problems in a Python tutorial, book, Internet search or Stack Overflow - but if not, come back and ask a more specific question, showing your attempted code and the problem you are having with it.