Drop links or images here to add them to the editor.

In a predict and run task you do not write code from scratch. You start from a small piece of working code, work out what you think it will do before you run it, and then run it to check whether you were right.

This task contains one example.

Predict

Study the code below carefully and write down a prediction of what it will do when it runs. Your prediction should use the key terms variable, assign and concatenate. You can type your prediction straight into the code as a comment, on a line starting with #.

Work out these things in particular:

Only once you have written your prediction should you run the code and compare the result with what you expected.

Need more help with input? Click here.

The code

print("Hi! What's your name?")

name = input()

print("Hi " + name + "! How are you today?")

Run it, type a name and press enter. Then run it a second time with a completely different name and check that your prediction still holds. The program is the same both times; only the data it collects has changed.

Help! My code doesn't work!

Make sure that you check for the following things:

  • You have put the brackets after the input command.
  • You have typed the variable name exactly the same, capital letters included, every time.
  • There is a variable on the left of each assignment, and the data is on the right.
  • You have used a single = for assignment.
  • You have used the + symbol to concatenate (join).