Studyfin Studyfin ✨ Sign up free

Strings & string manipulation

Grade 5 · Coding · Free lesson

Hi there! I am Studyfin, your friendly coding buddy. Today, we will learn how computers use text!

In coding, we call any text a string. A string is just a line of letters, numbers, or symbols. We wrap them in quotation marks so the computer knows it is text.

We can join two strings together to make a new, longer string. This is called concatenation. It is like gluing two words together with a plus sign!

"Sun" + "shine" "Sunshine"

Sometimes we want to repeat a message. We can use a nested loop to print our strings inside another loop. We do this to solve different parts of a big task step by step.

Outer Loop (Repeat 2 times) Inner Loop (Print "Hi!" 3 times) "Hi!" "Hi!" "Hi!"
✏️ Worked example

We want to write a program that prints a pattern for a game. It needs to print two rows. Each row must print the word 'Go' three times in a row.

  1. First, we plan our program using a software design process. We break the big goal into smaller tasks.
  2. Our first subproblem is to print the word 'Go' three times. We can do this by adding strings together inside an inner loop.
  3. Our second subproblem is to repeat that whole row two times. We will use an outer loop for this.
  4. We put the inner loop inside the outer loop. This is called a nested loop.
  5. When we run the code, the program prints 'GoGoGo' on the first line, and 'GoGoGo' on the second line!
Want the full interactive lesson — quiz, animations, and Finn cheering them on?

More Coding lessons