Okay, so I wanted to make a fun little Super Mario quiz. Nothing fancy, just something to test my friends’ knowledge of the Mushroom Kingdom. I figured a simple command-line thing would be perfect.
First, I brainstormed some questions. You know, the classics: “What’s Mario’s brother’s name?” “What’s the princess’s name?” “What does Mario use to get bigger?” That kind of stuff. I wrote down about ten questions and their multiple-choice answers. Easy peasy.
The Code Part
Next, I opened up my text editor. I’m using Python for this because, it is pretty straightforward for this sort of thing.
I started by creating a list. Each item in the list was a dictionary, holding the question, the answer choices, and the correct answer. Something like this:
'options': ["A. Mushroom", "B. Star", "C. Fire Flower", "D. Leaf"],
'answer': "A"
Then, I made a loop to go through each question. Inside the loop, I printed the question and the options. I used another, nested loop. It is used to print to options of A,B,C,D.
After printing the question and options, I asked the user for their answer using input(). Just a simple “Enter your answer (A, B, C, or D):”.
I also added a little check to make sure their input was valid. If they didn’t enter A, B, C, or D, I printed a little “Hey, that’s not a valid answer!” message and asked them again. And again. Until got the correct form of answer.
Finally, I compared their answer to the correct answer stored in the dictionary. If they got it right, I printed a “Correct!” message. If not, I told them “Nope, that’s not it” and revealed the right answer.
After they are done, I showed the marks.
Testing and Tweaking
Of course, I tested it myself first. I caught a couple of typos in my questions that way. Then, I sent it to a few friends to try out. They found a couple more things I could improve, like making the output a little clearer. The most important thing is I did it.
Overall, it was a fun little project! It didn’t take too long, and it was a good way to practice some basic Python. Plus, now I have a cool little quiz to challenge my friends with.