This week I tried to write a program to set ans ask random questions in a Scratch program.
Since we cannot read from a text file, I set the questions and answers in a list beforehand:
This will create two lists like this:
I made a third list to remember which questions have been asked before so that I do not ask the same question twice. I added the number of the question that I have asked to this list and then checked whether a number is already on this list before I asked it again.
On the stage, I displayed all the possible answers as follows, so that the player only has to input the number of his choice:
The code to ask 5 random questions and check whether the answers are correct:
Note: you can simply check whether Answer = questionNumber to see is the answer is correct.