circulate/sslc_science.py
author Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
Thu, 17 Jun 2010 20:58:42 -0400
branchscipy2010
changeset 407 b5d3b5ddac7b
parent 385 c70118cdde66
permissions -rw-r--r--
Added changes to session 1. Added some IPython tips.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
358
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     1
science = {}
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     2
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
for record in open('sslc1.txt'):
359
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
     4
#    record = record.strip()
358
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     5
    fields = record.split(';')
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     6
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     7
    region_code = fields[0].strip()
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     8
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     9
    if region_code not in science:
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    10
        science[region_code] = 0
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    11
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    12
    score_str = fields[6].strip()
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    13
385
c70118cdde66 Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 359
diff changeset
    14
#    score = int(score_str) if score_str != 'AA' else 0
c70118cdde66 Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 359
diff changeset
    15
c70118cdde66 Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 359
diff changeset
    16
    if score_str != 'AA':
c70118cdde66 Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 359
diff changeset
    17
        score = int(score_str)
c70118cdde66 Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 359
diff changeset
    18
    else:
c70118cdde66 Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 359
diff changeset
    19
        score = 0
358
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    20
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    21
    if score > 90:
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    22
        science[region_code] += 1
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    23
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    24
figure(1)
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    25
pie(science.values(), labels=science.keys())
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    26
title('Students scoring 90% and above in science by region')
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    27
savefig('science.png')