Knowledge organisersAdditional Programming Techniques
use of + between strings to join them together
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().
+ operator."Hello" + " " + "World" produces "Hello World".str() to convert numbers first.print("Name: " + name). Use + for concatenation, NOT commas.+ for concatenation. In Python, commas in print() just separate items — they don't join strings.sensorID = sensorType + sensorNumber concatenates two strings into one (line 04 is the concatenation line).word1 = "Hello", word2 = "Everyone", message = word1 + word2 → "HelloEveryone". Store the result in the specified variable — don't just print it.first = "Hello"
second = "World"
greeting = first + " " + second
print(greeting) # Output: Hello World
age = 16
print("Age: " + str(age)) # Must cast int to str