A file will consist of a series of questions and answers (design is also up to you). Here are two alternatives:
Each question has its own multiple-choices:
There are ways of telling whether she is a witch:
What do you burn apart from witches?
more witches,ice cream,vacuum cleaners,wood
Why do witches burn?
that's what they do,they are evil,because they are made of wood
Does wood sink in water?
yes,no -- it floats
What else floats in water?
bread,apples,churches,a duck
With the user interface looking like this:
There are ways of telling whether she is a witch:
1) What do you burn apart from witches?
A. ice cream
B. vacuum cleaners
C. wood
D. more witches
Your answer: C
Correct!
2) Why do witches burn?
A. they are evil
B. that's what they do
C. because they are made of wood
Your answer: C
Correct!
3) Does wood sink in water?
A. yes
B. no -- it floats
Your answer: B
Incorrect! The answer is yes.
Or alternatively, all questions could follow the same pattern and distractors would come from other answers in the file:
This will ask about world capitals.
What is the capital of _?
What country has _ as its capital?
France,Paris
Egypt,Cairo
Japan,Tokyo
Peru,Lima
The program will read the contents of the file and then create a quiz from those questions:
What is the name of the question file? capitals
This will ask about world capitals.
What is the capital of Japan?
A: Cairo
B: Tokyo
C: Buenos Aires
D: Timbuktu
Your answer: B
Correct!
What is the country has Lima as its capital?
A: France
B: China
C: Peru
D: Panama
Your answer: A
Incorrect! The answer is Peru.
What is the capital of Assyria?
A: Nineveh
B: Babylon
C: Jerusalem
D: Edo
Your answer: I don't know that!
Incorrect! The answer is Nineveh
You got 1 answers correct out of 3, which is 33%
At least 10 questions should be asked out of a question bank of at least 15. Questions should be chosen at random from the collection, without repeating. Multiple choices should also be shuffled.
It is expected that there will be at least two distinct functions defined for this project. Each function's purpose should be summarizable in one or two sentences.
Each function should have a meaningful name and meaningful parameters. Each should have a docstring (using triple quotes) at minimum describing what the function does. The complete interface should be clear from the function heading and its documentation.
The function certainly may define additional local variables to complete its task. The parameter list should only contain values and variables that must be shared with its caller, and no other hidden communications (such as no global variables).
The data files are intended to allow a great deal more flexibility in the application areas without having to modify the program code. Each program is expected to get all of the content data from the data files. The content is not to be hard-coded into the Python code itself.
The program must prompt the user for the name of a data file. Whether you require the user to type an extension (such as ".txt") or whether the program automatically adds the extension is up to you. You may assume that the user running the program knows the name of an existing data file in that same folder. This requirement is one means of assuring that your program can accept any applicable data file and is not restricted to very particular content.
Your program should not make any particular assumptions about the exact size of the data file. It should just be able to read to the end of the file (the for loop can do that). A recent recitation demonstrated that it is rather easy to identify how many file lines were actually found, and the program can then make use of that number.
The Overview already suggested that this should be able to supply the questions in a random order.
Similarly, it may be a good thing to have the choices in a multiple-choice question to be in a random order (so it is not always answer A). Just be sure that your program remembers which answer is the correct one after they are mixed around.
If there are a large number of questions, it might be appropriate to just pick a subset. For example, a quiz about US state capitals should not ask about all 50 states, but maybe 10 or 15 of them. You can use whatever means you wish to pick the size of your subset (such as 10, or 1/3 of the total, or some combination). If there is a very short list of questions, however, it would make more sense to ask them all.