How to calculate proof notes?

2

I am writing a code that prints a student's grade according to the number of questions he hits. But I need the program to do the calculation in a specific amount of times. The program should receive the number of questions in the test, the feedback of the test (the proof is objective), the number of students who took the test and the response of each student. The program must print the note of each student, and the student receives 1 point for the correct question. Example:

Entry:

5
ABCDD
2
ABCDD
ACCDE

Output:

5
3

Another example:

Entry:

3
DAA
3
ABA
DDA
BBC

Output:

1
2
0

How do I do:

questões = int(raw_input())
gabarito = raw_input()
alunos = int(raw_input())
resposta = raw_input()
nota = 0
for i in resposta:
   if i == r in gabarito:
      nota = nota + 1
   print nota

My difficulty is in getting the code to receive the specified number of entries. Would it work fine by defining a function, or does it not? How to proceed?

    
asked by anonymous 04.04.2016 / 21:36

1 answer

2

In the question, it is a x amount of students passed through the exercise, it is in that part that you are wrong.

When picking up the number of students who answered the feedback, you have to enter a repetition structure to capture all students, and then check each student's feedback.

Another thing, it's a little strange for your condition if i == r in gabarito , in is using to search for the value inside the string or array ex:

if 'msg' in "Name of message is msg, end of string":

The condition will look for string "msg" inside the other string , so in the case of the template, even if the order is wrong, the code would consider it correct.

Resolved Code:

#!/usr/bin/env python2.7
# o método input() recolhe valores inteiros, não há
# necessidade de conversão
# o raw_input() recolhe strings, mas só é disponível
# para o python2.x, no python3.x, só possui o método
# input() recolhendo string
quest = input()
gabar = raw_input()
aluno = input()

for x in range(aluno):
    resp = raw_input()
    nota = 0
    for x in range(len(resp)):
        if gabar[x] == resp[x]:
            nota+=1

    print nota
    
04.04.2016 / 22:55