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.