I tried to do something as simple as possible. See:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
respostas = [
['a', 'b', 'c', 'd', 'e'],
['d', 'c', 'c', 'a', 'd'],
['d', 'c', 'd', 'b', 'a'],
['d', 'c', 'c', 'b', 'e']
];
gabarito = ['d', 'c', 'c', 'b', 'e']
for r_num, resposta in enumerate(respostas):
total = 0;
for g_num, valor in enumerate(gabarito):
# Se a posição do valor do gabarito é o mesmo da resposta e os valores iguais
if resposta[g_num] == valor:
#Suponhamos que cada acerto vale 2 pontos
total = total + 2;
print "O aluno %s tirou %d pontos" % (r_num, total)
When running the above code, the result should be:
O aluno 0 tirou 4 pontos
O aluno 1 tirou 6 pontos
O aluno 2 tirou 6 pontos
O aluno 3 tirou 10 pontos
Supposing you have some notion of python
, realize that the passage resposta[g_num]
I capture through the feedback index the value of one of the answers. This is because, in a feedback, there is a number of the question (which would be the index in our case), and therefore must hit, at the same time, the question number and answer value.
That’s what I got. I don’t know if in this case the use of a list
would be ideal.