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

In an investigate task you take working code apart to see how each piece contributes to the result. Answer every question for yourself first. You can edit the code and run it to check. Only then open the answer.

name = "Billy"
print("We want to know if you like programming!")
print()
print("Do you like programming " + name + "?")
answer = input()
print("Great, " + name + ", you said " + answer + "!")
print("Let's learn some Python today")

How many output statements are used in the code?

Answer

Five. Every print is an output statement, and there are five of them: the four that output text, plus the empty one.

answer = input() is not one of them. It is an input statement: it collects data instead of presenting it.

What symbol is used for concatenation?

Answer

The + symbol. It appears twice in print("Do you like programming " + name + "?"), joining a string, the contents of a variable and another string into one piece of text, and four times on the line below that.

What is the purpose of the program?

Answer

It holds a very small conversation. It announces what it wants to know, asks the user whether they like programming, and repeats the answer back to them by name.

The interesting part is that only half of that conversation is real. The answer is genuinely collected from the user with input(), but the name is not: it is hardcoded as "Billy", so the program greets everyone as Billy no matter who is using it.

Which lines use assignment, and what is assigned on each of them?

Answer

Two lines use assignment:

  • name = "Billy" assigns the string "Billy" to the variable name.
  • answer = input() assigns whatever the user typed to the variable answer.

The second one is worth a closer look. The data on the right of the = is not something written out in the code; it is the result of running input(), which is only known once the program is running. Without that = and that variable name, the typed answer would be read and then discarded.

What symbol is used for assignment?

Answer

A single =. It is read as “gets the value”: the variable on the left gets the data on the right.

What is the purpose of the empty print()?

Answer

It outputs a blank line, which separates the opening announcement from the question underneath it and makes the conversation easier to read.

A print always moves to a new line when it has finished. Give it nothing to output and that is all it does, so an empty print() costs one line of code and buys one empty line of output. Delete it and the output still makes sense, but the two lines run into each other:

We want to know if you like programming!
Do you like programming Billy?
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).