i'm failing to calculate avarage on my web2py application!!!! But its
supposed to be very simple, i have been able to calculate the percentages
for all the marks now i want to add up all those percentages and divide
them by the number of subjects, get the avarage percentage and grade a
student. I've been trying to get the total addition for the percentage by
doing an incremental addition on a variable that will hold the value but
its only taking one percentage value and ignoring others. Maybe i'm just
bad at math can some one please help me. Here is my code.
<div class="grades">.............................................{{
average=0for report in form:
perc=(float(report.marks)/float(report.total))*float(100)if perc>=75:
grade='A'elif perc>=65:
grade='B'elif perc>=55:
grade='C'elif perc>=45:
grade='D'
This is where I'm attempting to calculate the average
average+=perc
average2=int(average/7)}}
{{pass}}
<tr><td>{{=report.term.term}}</td><td>{{=report.subject.subject_name}}</td><td>{{=report.marks}}</td><td>{{=report.total}}</td><td>{{=perc}}(%)</td><td>{{=grade}}</td></td><td>{{=report.comments}}</td></tr>
{{pass}}{{pass}}</table></div><div class="grades" style="margin-left:
5px;"><table><tr><th>AVERAGE</th><th>T/GRADE</th><th>CL/PS</th><th>SC/PS</th></tr><tr>
This is where i call the average variable
<td>{{=average2}}(%)</td><td>Grade A</td><td>3</td><td>21</td></tr>
</table>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.