Quiz Program – Part 2: adding to the quiz

Option 2 – Using the user's name

It would be nice to be able to address the user by their name.

This is quote easy to do, we just need to get them to enter their name and store it in a variable.

The first thing to do is to get the user to enter their name using an input statement.

Add this after your introduction, towards the top of your code

Code helper image
  1. Start by leaving a blank line using:  print()
  2. Then use something like  name = input("Enter your name > ")

That gets the name. But now we need to use it.

Using the name

Code helper image

To use the name you need to join the variable with a set of words (called a string).

You can do this in lots of different ways. The screenshot should give you some ideas of the sorts of things you can do.

IMPORTANT: the commas are really important in these bits of code. They link the variable to the string.

There are other things you can do using the name. Ask if you have something in mind...