author | Puneeth Chaganti <punchagan@fossee.in> |
Sun, 10 Jan 2010 16:57:51 +0530 | |
changeset 344 | 19754ed6050f |
parent 64 | 333092b68926 |
permissions | -rw-r--r-- |
64
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
import math |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
|
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
f = open('/home/madhu/Desktop/marks.dat') |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
4 |
|
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
5 |
subj_marks = [[]] * 5 |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
6 |
names = [] |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
for line in f: |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
8 |
fields = line.split(';') |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
9 |
names.append(fields[2]) |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
10 |
for i in range(5): |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
11 |
subj_marks[i].append(int(fields[i+3])) |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
12 |
|
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
13 |
for i in range(5): |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
14 |
avg_marks = float(sum(subj_marks[i])) / len(subj_marks[i]) |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
15 |
student = names[subj_marks[i].index(max(subj_marks[i]))] |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
16 |
sigma = 0 |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
17 |
for j in subj_marks[i]: |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
18 |
sigma += (j - avg_marks) ** 2 |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
19 |
|
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
20 |
std_dev = math.sqrt(sigma) |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
21 |
print "Average marks for subject: %f is Standard Deviation is %f, Student with Highest Marks is %s" % (avg_marks, std_dev, student) |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
22 |