Note that there are some explanatory texts on larger screens.

plurals
  1. POApplying a function to various keys in a dictionary at a time
    primarykey
    data
    text
    <p>How can I update the print_quiz_averages function so that it will print all scores for each person at a time, instead of showing every person's score for each item?</p> <pre><code>from __future__ import division def main(): quiz_averages = quiz_average(remove_zeros([57,0,36,29,38,31,33,0,42,0,52,28,0,50,26,97,80,63,8,36,33,39,12,36,12,59,75,61,57,39,18,9,19,35,75,5,18,0,56,0,24,0,9], [83,0,64,45,66,82,52,0,43,0,53,49,43,82,44,74,74,58,52,52,60,18,24,34,19,42,72,65,79,99,75,24,35,70,74,43,55,0,82,0,34,0,22], [69,0,38,16,16,16,55,0,28,0,44.5,31,0,33,52,75,46,33,36,0,49,34.5,35,79.5,13,27,31,52,40.5,64.5,15,0,31,47,26,0,36,0,68,0,64.5,0,20], [86,0,95,74,90,53,32,0,79,0,38,63,0,42,61,0,0,70,62,78,0,60,47,89,75,62,84,62,71,80,73,0,31,25,74,0,77,0,90,0,78,0,25])) student_quiz_scores = {'Raven':[61,65,52,62], 'Jacob':[39,99,64.5,80], 'Jessica':[35,70,47,25], 'Joe':[57,79,40.5,71], 'Aaron':[18,75,15,73]} print_quiz_averages(student_quiz_scores,quiz_averages) def quiz_average(all_quizzes): averages = [] for each_quiz in all_quizzes: each_average = find_average(each_quiz) averages.append(each_average) return averages def print_quiz_averages(student_quiz_scores,the_averages): for i, average in enumerate(the_averages): print "\nThe average for quiz",i+1,"is:",average for student, student_data in student_quiz_scores.iteritems(): if student_data[i]&gt;average: print student, "got a",student_data[i],"which is",(str(student_data[i]-average))+"%", "higher than the average. :)" else: print student, "got a", student_data[i], "which is", (str(-student_data[i]+average))+"%", "lower than the average. :(" if __name__ == '__main__': main() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload