Can anyone elucidate exactly what the course_grader function call is passing to the course_grader function using the ([n, n, n]) argument, and how the course_grader function is storing those parameters using a non-specific variable called “test_scores”?
It looks to me like it is passing an array(list), but i don’t recall that being covered to this point.
I’m presuming I will somehow have to iterate through the values of the parameter set and add them to an accumulator variable to determine the sum, and then somehow determine the length of the parameter set in order to determine an average. I understand the logic of the problem perfectly well–it’s the secret knowledge of the syntax that is making this exercise overly time consuming.
Enlightenment would be helpful…thanks in advance.
A hint is-- it helped me to set up a variable that would indicate “0” if the student failed, and not “0” if they passed. That variable could be used for multiple instances.
I am having similar problems with the syntax. So far, I’ve been able to set up the algorithm for finding the average score and half of the conditions. However, I’m unsure how to determine the other half of the conditions regarding the score being below 50 or not. Is there a method that can find an integer within a list or convert the list into an int that could be used with an operator? It continues to return this error:
unorderable types: list() < int()
The argument to the function is a list of grades. You might find it useful to write a helper function that calculates the average of a list of numbers and make use of that in the course_grader function.
My function is calculating the average properly, according to the codelens. But, it’s not able to return the correct message because the condition of a score being (or not being) below 50 is not being read by the interpreter. Only 3 of the 5 are printing the right message. I’ve looked about stackoverflow and the chapter about lists in the book to figure out how to find a number that is < 50 in a list, but haven’t found the right method yet.
“Or” is the key to your success.
Depending on how she solves it, and might be the correct boolean operator.
The problem states :
If (the average score is greater than or equal to 70) and (no single test score is below 50)
return a message of “pass”.
If the above condition is not met, then “fail”
Different ways of accessing nums in a list of nums to determine if any are less than 50. One way is with a loop. Another is to sort the list from low to high with sorted(a_list).
if you have a “for i in list of scores:” loop within the definition of your course_grader() function, you can check for the value of i within that loop, and set it to “pass” or “fail” i based on its value each time the loop runs (in addition to other evaluations of values further along in your function definition).
i ran into the same problem as you and realized where the snag was after going over my code in codelens - if you simply evaluate i further down in your function definition (without sorting the list or performing another operation on it), it will check only the most recent value for i that it encountered.
this may not be the best way to solve the issue, but it works! hope this helped
I was able to solve it! I accessed the nums in the list to determine if any are less than 50. Thank you for your help!
I was able to solve it! I was able to use a for loop to check for the value within the list, and set it to “pass” or “fail”. But I worried that there was probably another way to solve it without using a for loop . I might try to work on it more later on to see if there are different ways to solve it. Thank you for your help!
yay! i’m so glad you figured it out. there are definitely other ways to do it and i’m sure it would be helpful to keep working at it, but at least this way works haha
I keep getting pass for all five instead of pass & fail.
Not sure what I am missing.
Is there an average function I should be using?
I have an if and elif for the two grade levels.
Yes, you do need to assign the average test score to a variable and use it in your function. Try just solving the “fail” conditions and see if the “pass” will work itself out…
Can you say more about the problem you’re facing? Which set(s) failed? Do you know why it failed, e.g., because it’s not correctly computing an average score, because it’s not correctly recording an instance of a score below 50, because your condition testing is not picking up an average score that is below the passing limit, or because your condition testing is not picking up a score below 50?
To figure it out, try setting up your own function call to course_grader using one of the failing data sets as the argument (make sure the syntax and data match the syntax and data in the test set EXACTLY). Then, step through it using codelens. Before each step, predict what it will reveal, then click to step forward and compare your answer to what the program shows. If the answers are different you know where to focus your problem solving. Note that you may have to do this many times to find all the problems!
Let me know if this helps…I’ll be close to my computer most of the day so I’ll try to stay on this with you if you need more help.
See what I wrote above. The problem statement tells you what you need in terms of if statements and logical (i.e. boolean) operators.