Trivia Python Project
Welcome to my Trivia Python project for Computer Science Principals.
This was written using Python 3.9, so it might not work 100% properly on 3.8. I have tried to ensure compatability.
To Run
Install the dependancy:
pip install -r requirements.txt
And simply execute main.py
About .questions format
Please make sure to follow the syntax properly. I have not yet implemented any syntax checking, so making a mistake might result in undefined behavior.
- Indentation is not required, but it is encouraged for readablity
.questions
files must end withend
on the last line, which signals the end of the file- Each question declaration is started with
q:
- After making a question, an answer token (
a:
) must be the next token used and it needs to be followed by a string that is a potential answer to the question. A user is prompted with all of the answers when playing - Each answer must be followed with one points value (an integer defined with the token
p:
) and one comment (a string defined with the tokenc:
) provding feedback about that answer to the user that selected it - Each question can have as many answers as you wish
- Lines that start with any thing that is not a token in the
.questions
format (the tokens areq:
,a:
,p:
,c:
, andend
) is ignored - For the program to detect the
.questions
file, it needs to be in the program directory. This can be changed by passing apathlib.Path
object to the call toget_question_files
in the main function inmain.py
- For a sample
.questions
file, seesample.questions
. You can also look at any of the other ones