Kids Coding
Words and Strings
A string is text in quotes. You can join words with + and print a sentence.
A string is text
Anything in quotes is a string: a row of characters. Names, sentences, and secret codes are strings.
Strings
print("hello")
print("hello" + " " + "world")Glue with +
+ on strings joins them. There is no extra space unless you add one yourself.
Remember the space
print("Good" + "morning")
print("Good" + " " + "morning")Strings and numbers are different
2 + 2 is 4. "2" + "2" is "22". Quotes change the meaning.
Not the same
print(2 + 2)
print("2" + "2")You cannot add a string to a number. print("Score: " + 10) fails. Turn the number into text with str(10), or use a comma in print.
Real life
Writing a birthday card.
You glue “Happy” and “Birthday” together. + on strings does that join.
Birthday card
print("Happy" + " " + "Birthday" + ", " + "Riley" + "!")Change one word. Run it. That is how this idea shows up outside the lesson.
Try it
Exercise 1: Join your first name and last name with a space and print the full name.
Show solution
print("Sam" + " " + "Lee")