3
I’m writing a code that prints a student’s grade according to the number of questions he gets right. But I need the program to do the calculation in a specific amount of times. The program must receive the amount of questions in the test, the feedback of the test (the test is objective), the amount of students who took the test and the response of each student. The program must print each student’s grade, and the student receives 1 point for the correct question. Example:
Entree:
5
ABCDD
2
ABCDD
ACCDE
Exit:
5
3
Another example:
Entree:
3
DAA
3
ABA
DDA
BBC
Exit:
1
2
0
Like I’m doing:
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 be right to define a function, or not accurate? How to proceed?
I don’t understand that line:
if i == r in gabarito
. Also, your code does not run-- is without parentheses inraw_input
.– Pablo Almeida
If the answer item is contained in the template. Typing error.
– Guilherme Santana De Souza
Do you understand that you are looking for a Boolean inside a String on that line? Also, what is
r
?– Pablo Almeida
I do not understand, I will study the subject. 'r' would be the variable representation of each item in the answer. I made a mistake. Thanks for the tips.
– Guilherme Santana De Souza