Paul's Python CoursePPC

Project 1 of 12, for Yahya

NumPy Grade Book

A grade book for a whole class, in one NumPy array: averages, a curve, z-scores, dropped marks and grade bands, without a loop. On real marks from two schools in Portugal.

About an hour and a half, in 15 steps.

Sign up free to open itLog in

Act 5 needs a free account, so your work is saved as you go. Act 1 is open to everyone.

The brief

  • YahyaPaul asked me how the class's marks are spread, and he wants it done properly rather than by eye.
  • YahyaOurs are private, though, so I'm practising on some real marks that aren't.
  • YahyaTwo schools in Portugal published theirs, which is three hundred and ninety-five students with three marks each.
  • PaulTreat it as one block of numbers and don't do anything one student at a time.

marks.csv is real data: the maths marks of 395 students at two secondary schools in Portugal, published by Paulo Cortez and Alice Silva in 2008. One row per student: an anonymous number, the school, and three marks out of 20, the first period, the second period and the final. load_marks is written. It gives back students, the 395 numbers, and marks, an array of 395 rows and 3 columns.

Write six functions. None of them needs a loop.

  • student_means(marks): each student's average, one number per student.
  • assessment_means(marks): each assessment's average, one number per column.
  • curve(marks, target): add to every mark in an assessment the amount that would bring that assessment's average to target, then keep every mark between 0 and 20. Leave marks as it was.
  • z_scores(marks): how many standard deviations each mark is above or below its assessment's average, as an array the same shape as marks.
  • dropped(marks, by): True for each student whose final (the last column) is at least by marks below their first (column 0), False for everyone else.
  • bands(final): the band of each final mark, as an array of letters: A from 16, B from 14, C from 12, D from 10, F below 10.

The report at the bottom of the file is written too. It uses your functions.

What it prints
395 students, 3 assessments
Average by assessment: [10.9 10.7 10.4]
Best average: student 48, 19.3
After a curve to 12: [12. 12. 12.]
Finals more than two deviations below average: 38
Dropped 3 marks or more, first to final: 47
Final bands: A 40, B 60, C 62, D 103, F 130

What you learn

What's in it

  1. A block of numbers
  2. Twice the marks
  3. Rows and columns
  4. Row first
  5. The axis that disappears
  6. Coldest each day
  7. No loop needed
  8. A whole class in one block
  9. Stretching to fit
  10. Odd shapes
  11. How Paul would do it
  12. Fix Aaesha's version
  13. Make the grade book
  14. Ship it