Revise Computingrevisecomputing.co.uk
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates

Knowledge organisers / Additional Programming Techniques

The use of basic string manipulation: Concatenation

All topicsPractise exam questions
Knowledge organiser

Additional Programming Techniques

2.2.3a

use of + between strings to join them together

What you need to know

String concatenation is the process of joining two or more strings together using the + operator. This is commonly used to combine text with variable values for output. When concatenating, all values must be strings; numbers need to be cast to strings first using str().

Key points

  • Definition:Concatenation: joining two or more strings together using the + operator.
  • Example: "Hello" + " " + "World" produces "Hello World".
  • All values being concatenated must be strings; use str() to convert numbers first.
  • Useful for building output messages that include variable values.
  • In OCR pseudocode: print("Name: " + name). Use + for concatenation, NOT commas.
  • Common Mistake:Using a comma instead of + for concatenation. In Python, commas in print() just separate items — they don't join strings.
  • Exam Example:sensorID = sensorType + sensorNumber concatenates two strings into one (line 04 is the concatenation line).
  • Exam Tip:word1 = "Hello", word2 = "Everyone", message = word1 + word2 → "HelloEveryone". Store the result in the specified variable — don't just print it.

Code examples

String concatenation
python
first = "Hello"
second = "World"
greeting = first + " " + second
print(greeting)  # Output: Hello World

age = 16
print("Age: " + str(age))  # Must cast int to str