Python : How to make a quiz and check if the answer is correct?
<p>I'm taking a computer science course and I recently took a test and there was a question whose answer I did not know  and I want to know how to do it.</p>

<p>The Question/problem was Ask the user 7 questions. Then check how many were correct and then give a percentage. I am familiar with input and operators and variables but I do not understand how to check if the answer the user inputed was correct and how to calculate how many were correct and how many were incorrect</p>

<p>How about something like this (pseudo-code)?</p>

<pre><code>qa = [
    ('Q1', 'A1'),
    ('Q2', 'A2'),
     ]
num_correct = 0

for q,a in qa:
    user_answer = raw_input(q) 
    if user_answer == a:
        num_correct += 1

print 'Total questions:', len(qa)
print 'Total correct:', num_correct  
</code></pre>

<p>You should be able to find out the rest.</p>

python input