[Solved]Python 3 Simple Quiz File Consist Series Questions Answers Something Like Ask Capitals Sev Q37083151
Python 3
A simple quiz
A file will consist of a series of questions and answers,something like this:
This will ask for the capitals of several countries.What is the capital of France?,ParisWhat is the capital of Egypt?,Cairo
The program will read the contents of the file and then quiz theuser:
What is the name of the question file? capitalsThis will ask for the capitals of several countries.What is the capital of Japan? tokyoCorrect!What is the capital of Peru? LimaCorrect!What is the capital of Assyria? I don’t know that!Incorrect! The answer is NinevehYou got 2 answers correct out of 3, which is 67%
At least 10 questions should be asked out of a question bank ofat least 15. Questions should be chosen at random from thecollection, without repeating. Also, answers should becase-insenstive (i.e. upper or lowercase letters should be equallygood).
Use of Functions
It is expected that there will be at least two distinctfunctions defined for this project, as specified for Homework 6.Each function’s purpose should be summarizable in one or twosentences. The lecture slides indicated that a function should befewer than 30 lines of code (or not much more than that), notcounting documentation and blank linles.
Each function should have a meaningful name and meaningfulparameters. Each should have a docstring (using triple quotes) atminimum describing what the function does. The complete interfaceshould be clear from the function heading and itsdocumentation.
The function certainly may define additional local variables tocomplete its task. The parameter list should only contain valuesand variables that must be shared with its caller, and no otherhidden communications (such as no global variables).
If your submitted project design seems insufficient to theseexpectations, you are certainly permitted (and encouraged) toimprove upon it, since that will help you to complete the programon time.
In any case, any program that has _no_ functions defined, butdoes everything without functions (as Homeworks 1-4) will not earnfull credit, even if it does otherwise work correctly.
Use of Data Files
The data files are intended to allow a great deal moreflexibility in the application areas without having to modify theprogram code. Each program is expected to get all of the contentdata from the data files. The content is not to be hard-coded intothe Python code itself.
To be more specific for the recommended projects:
— quiz program: data file has all questions and all answers
— hangman: data file consists of the possible words to be guessedat
— madlib: data file consists of all the text and prompt words forthe madlib
No other examples will be given here, since other projects areconsidered on a case by case basis, and should have been approvedin advance. For those who still were not aware that this was not acompletely open-ended design-your-own project, you may still needto find a way to assure that the program code is as unaware of datacontent as possible.
The program should prompt the user for the name of the datafile. Whether you require the user to type an extension (such as”.txt”) or whether the program automatically adds the extension isup to you. You may assume that the user running the program knowsthe name of an existing data file in that same folder.
If you wish to remove that assumption, and give a user a list ofchoices of available files, you may do so, for 10% Extra Credit.This would require getting a list of files from the OperatingSystem (consider the ‘listdir’ method in the ‘os’module).
Your program should not make any particular assumptions aboutthe exact size of the data file. It should just be able to read tothe end of the file (the for loop can do that). A recent recitationdemonstrated that it is rather easy to identify how many file lineswere actually found, and the program can then make use of thatnumber.
Special Hint
Here are a few things that would make the assigned projects alittle interesting, with some hints about how to go about them.
Quiz Program:
The Overview already suggested that this should be able tosupply the questions in a random order, and the Blackjackrecitation referred to a function that would be very helpful forthat.
If there are a large number of questions, it might beappropriate to just pick a subset. For example, a quiz about USstate capitals should not ask about all 50 states, but maybe 10 or15 of them. You can use whatever means you wish to pick as a subset(such as 10, or 1/3 of the total, or some combination). If there isa very short list of questions, however, it would make more senseto ask them all.
Expert Answer
Answer to Python 3 A simple quiz A file will consist of a series of questions and answers, something like this: This will ask for … . . .
OR

