circulate/sslc_science.py
changeset 358 162e3e453920
child 359 cb17c87b090e
equal deleted inserted replaced
355:6af6441034f9 358:162e3e453920
       
     1 science = {}
       
     2 
       
     3 for record in open('sslc1.txt'):
       
     4     record = record.strip()
       
     5     fields = record.split(';')
       
     6 
       
     7     region_code = fields[0].strip()
       
     8 
       
     9     if region_code not in science:
       
    10         science[region_code] = 0
       
    11 
       
    12     score_str = fields[6].strip()
       
    13 
       
    14     score = int(score_str) if score_str != 'AA' else 0
       
    15 
       
    16     if score > 90:
       
    17         science[region_code] += 1
       
    18 
       
    19 figure(1)
       
    20 pie(science.values(), labels=science.keys())
       
    21 title('Students scoring 90% and above in science by region')
       
    22 savefig('science.png')