Skip to content

Instantly share code, notes, and snippets.

@niroyb
Last active January 3, 2016 04:59
Show Gist options
  • Save niroyb/8412302 to your computer and use it in GitHub Desktop.
Save niroyb/8412302 to your computer and use it in GitHub Desktop.
Analyse du fichier des résultats d'un cours à l'École Polytechnique de Montréal pour déterminer les seuils de chaque note. Idée de EtiDuc : https://github.com/EtiDuc/poly-seuils-notes
'''Groupe les notes et permet de trouver les seuils'''
import re
from collections import defaultdict
with open('Resultat.txt') as f:
text = f.read()
matches = re.findall('((?:[A-F])(?:\*|\+|\s))\s*\|\s*([0-9.]+)', text)
print len(matches), 'notes :'
lettre_notes = defaultdict(list)
for lettre, note in matches:
lettre_notes[lettre].append(float(note))
for lettre, notes in sorted(lettre_notes.items(), key=lambda x:max(x[1]), reverse=True):
print '{:<2} ({:>2}) [ {:>5.2f} - {:>5.2f} ]'.format(\
lettre, len(notes), min(notes), max(notes))
@niroyb
Copy link
Author

niroyb commented Jan 14, 2014

Example output :

70 notes :
A* ( 7) [ 18.03 - 18.65 ]
A  (19) [ 16.50 - 17.95 ]
B+ (22) [ 15.43 - 16.29 ]
B  ( 6) [ 14.59 - 15.23 ]
C+ (10) [ 13.48 - 14.26 ]
C  ( 4) [ 12.24 - 13.05 ]
D+ ( 1) [ 11.18 - 11.18 ]
F  ( 1) [  8.30 -  8.30 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment