A Quiz That Keeps Score
๐ฏ The program asks questions from a list, checks the answers, and gives a mark at the end.
๐ก The idea behind it
Lists hold many values, so the questions live in data rather than in the code โ which means adding a question does not mean rewriting anything.
๐งฑ Blocks you will need
ask and waitansweradd to listitem of listlength of listif โฆ then โฆ elserepeat
๐จ Build it
- Make two lists: questions and answers. Put the first question in item 1 of each.
- Make a variable n, set to 1, and a variable score, set to 0.
- repeat (length of questions): ask (item n of questions) and wait.
- if (answer) = (item n of answers) โ change score by 1 โ say 'Correct!' else โ say (join 'The answer was ' (item n of answers)).
- change n by 1, and after the loop, say the final score.
๐ Make it harder
- Shuffle the questions so the order differs each time.
- Save high scores in a third list and show the best three.
๐ Bugs you will hit
- It always says wrong: Scratch compares text exactly, so spaces and spelling matter. Trim your list entries.
- It asks the same question forever: you forgot 'change n by 1' inside the loop.
โฌ Need Scratch itself?
Free from MIT, in a browser or as an offline app that needs no connection at all.