Apr-21-2020, 08:47 PM
(This post was last modified: Apr-21-2020, 08:47 PM by deanhystad.)
A class is a good idea. Can also used lists, tuples or named tuples. This uses a list of tuples.
As for typing questions into the program, that is something I would only do to at a very short while. Eventually you will want a way for your quiz program to import questions from some other resource. Maybe that will be a json file. Maybe a sql database. Maybe you will scrape questions from the internet. Maybe there is a network of quiz makers and they have a standard format and set of tools.
questions = [ \ ("What is the capital of Colombia?", "Bogota"), ("What is the capital of Chile?", "Santiago")] for question, answer in questions: # Ask the question ...A nice thing about classes is you could do subclassing for different kinds of questions. They would share some basic methods like asking the question and verify the answer. You might have a fill in the blanks class, a T/F, a multiple choice, beat the buzzer type questions, etc. Each of these questions would know how to ask the question in the context of your quiz program and how to evaluate the answer. Eventually you could support questions that use multimedia.
As for typing questions into the program, that is something I would only do to at a very short while. Eventually you will want a way for your quiz program to import questions from some other resource. Maybe that will be a json file. Maybe a sql database. Maybe you will scrape questions from the internet. Maybe there is a network of quiz makers and they have a standard format and set of tools.