String Concatenation, online

Six activities your students do on their own devices. See who's finished, and their scores.

String Concatenation in one minute

What students need to know

Adding ' ' between strings inserts a space in the result. Variables holding strings can be concatenated with +.

There's already a space inside 'Hi ' — it gets joined to 'there'. name holds 'Alice', so 'Hi ' + name is 'Hi ' + 'Alice' = 'Hi Alice'.

Mistakes students make

  • Line 3 is missing the + operator. Use: first + second.
  • Line 2 uses Name with a capital N. Python is case-sensitive. Use: name.
  • Line 3 is missing a space before fruit. Use: count + " " + fruit.
  • Line 3 has a comma without quotes. Use: city + ", " + country.
PREVIOUS · MODULE 6Basic Arithmetic
YOU ARE HERE · MODULE 7String Concatenation
NEXT · MODULE 8String Repetition

Discover other journeys with this module

What students will learn in this module

Every question in Module 7

Quick questions

  1. What is "Hello" + "World"?AHelloWorldBHello World
  2. What is "Hi " + "there"?AHi thereBHithere
  3. After name = "Alice", what is "Hi " + name?AHi nameBHi Alice
  4. What is "Good" + "bye"?AGoodbyeBGood bye
  5. What is "Hello" + " " + "World"?AHelloWorldBHello World

Key terms

Students type the meaning of:

  • "Hello" + "World"
  • "Hello" + " " + "World"
  • name = "Alice"
  • "Hi " + name

Match the pairs

'Hello' + 5Match it to what it does
name = 'Ali'
print('Hi' + name)
Match it to what it does
'Hello' + ' ' + 'World'Match it to what it does
greeting = 'Hi '
result = greeting + 'Bob'
Match it to what it does
print('cat' + 'nap')Match it to what it does
a = 'Hot'
b = 'Dog'
print(a + b)
Match it to what it does

Fill in the blanks

  1. result = "Hello" _ "World"
  2. name = "Alice"
    message = "Hi " _ name
    print(message)
  3. greeting = "Good" + _ _ + "morning"
  4. first = "Bob"
    last = "Smith"
    fullname = first + " " + ____
  5. city = "Melbourne"
    sentence = "I live in " + ____
    print(sentence)

Spot the error

Question 1

Afirst = "Hello"Bsecond = "World"Cresult = first secondDprint(result)

Question 2

Aname = "Bob"Bgreeting = "Hi " + NameCprint(greeting)

Question 3

Afruit = "apple"Bcount = "3"Cmsg = "I have " + count + fruitDprint(msg)

Question 4

Acity = "Melbourne"Bcountry = "Australia"Clocation = city + , + countryDprint(location)

Question 5

Aword = "Hello"Bsentence = word + " " + "World"Cprint(Sentence)