Quiz Program – Part 2: adding to the quiz

Option 1.1 – Presenting the final score

When people get to the end of the quiz they should have a final score.

What that score will be out of will depend on how you scored your quiz. I'll start by assuming that you just added a point if they got a question right – so the score will be out of 5.

The first thing we need to do is to tell them what their final score is. This bit's easy.

Code helper image
  1. Start by leaving a blank line using:  print()
  2. Then use something like  print("That's the end of the quiz")  to tell the user that the quiz is over
  3. Then use something like  print("Your final score is", score, "out of 5")
  4. Run your code to check that it works

That's the very basic level.

Adding some tension

Code helper image

You could add a bit of tension to the final score by getting Python to pause for a moment or two.

You can do this using a command called  sleep(), but you have to do something special to get it to work.

  1. Go right to the top of your code and add the instruction:  import time  right at the top

    This imports a set of commands into Python that it doesn't usually use

  2. Then we can use  time.sleep(2)  in between some print commands

    The 2 means to pause for 2 seconds. You can change this number – but don't make it too long as that's boring

  3. Don't forget to run your code to check that it works