This may be a stupid question, and I believe that there is a good chance that I take a completely wrong approach to solving my problem, so if someone knows the best way, please feel free to correct me / point me to the right.
I am trying to make a basic Python quiz program for fun, and I can’t find a good way to actually both answer questions with my answers and store the correct answers. Ideally, I would like to shuffle the answers in the question around, so for example, the answer to # 1 is not always "A", but it is too far at the moment.
In any case, I decided that the dictionary could work. I would do something like this:
test = {
'1': "What is 1+1?\nA) 2\nB) 11\nC) 1\nD) None of the above.\n\n",
'2': "What is 2+2?\nA) 2\nB) 4\nC) 1\nD) None of the above.\n\n",
'3': "What is 3+3?\nA) 2\nB) 11\nC) 6\nD) None of the above.\n\n",
'4': "What is 4+4?\nA) 2\nB) 11\nC) 1\nD) None of the above.\n\n",
'5': "What is 5+5?\nA) 2\nB) 11\nC) 10\nD) None of the above.\n\n",
'6': "What is 6+6?\nA) 2\nB) 12\nC) 1\nD) None of the above.\n\n",
}
answer = raw_input(test['1'])
, . , , , - if. - ? ? ? .