Quiz Program – Part 1: the basic quiz

Step 4 – Getting an answer

Now we need to ask the user for an answer.

THEORY: this is going to involve using a variable to store the user's answer. I'm going to call my variable answer because that makes sense to me.
Remember that a variable is just a named area of computer memory where we can store something.

  1. Code helper imageUnderneath the question type:  answer = input("Your answer > ")

    IMPORTANT: actually type the words "Your answer". This gives the user a prompt to type their answer in. Don't type the actual answer to your question!

    Don't forget the quotes (") and brackets. And do you see that I added a space after the symbol?

  2. Now run the program again. This time it waits for you to enter an answer
  3. Type an answer and press Enter. The program will just end at that point for now. That's OK

The > symbol is a classic way to show a player that they need to enter something.

THEORY: an input command lets you get the user to enter something. This could be a word, a number, a sentence or just getting them to press enter. You can store whatever the type in a variable and then use that data later on.

You can see my finished code by clicking the button below.

I left some gaps between my code. This just makes it easier to read. Which is a good thing.