Scratch exercise 39c

Quiz - advanced random using lists

This game will ask questions in a random order from a list of questions/answers, show the number of correct answers and say the correct answer if the player gets them wrong.

Complete these steps ..


1. Create a new game. Either open Scratch or if it is already open choose "File>New" ..



2. Add these scripts to the stage ..



3. Select the cat sprite and re-name him "Quizmaster".

Add this script to place him in the middle of the screen ..



4. Create the following variables ("for all sprites")..

Untick "Question number" and then place "Correct answers" under the Quizmaster on the stage ..



5. Create the following lists ..

Add some questions to the Questions list (at least 15-20 will be adequate).

Add the corresponding answers to the answers list (ensure the answer numbers match those of the questions).

For example ..

Hide (untick) the lists ..



6. Add these scripts to the quizmaster ..

Read the comments on the scripts above and try to understand what the script is doing. "Length of questions" returns the number of questions in the "Questions" list.



7. Save your game. Name it "quiz advanced".



8. You can add as many questions and answers to your lists as you like. The "length of questions" always returns the number of questions in the list.