Test your knowledge with free interactive questions on Seneca — used by over 10 million students.

Strings

Strings are special cases of arrays or lists, where each element is a character. There are many methods we can apply to them:

Concatenation

Concatenation

  • Concatenation is joining two strings together.
  • This can be done with the + sign. E.g:
    • "Hello " + "World" = "Hello World".
Accessing a character

Accessing a character

  • Remember, strings are just lists. So we can access a specific character in the exact same way as we access a list element:
    • string[3] would get the fourth character.
Length of a string

Length of a string

  • The length of a string is given by the len function:
    • len("Hello") would give 5.
Substrings

Substrings

  • A substring is a part of a longer string.
  • In pseudocode, we use the function:
    • stringname.subString(startPos, numberOfChars)
  • This takes a substring starting at the 'startPos'th character, and takes the stated number of characters.
Jump to other topics
1

Computer Systems

1.1

Systems Architecture

1.2

Memory & Storage

1.3

Computer Networks, Connections & Protocols

1.4

Network Security

1.5

Systems Software

1.6

Ethical, Legal, Cultural & Environmental Concern

2

Computational Thinking, Algorithms & Programming

2.1

Algorithms

2.2

Programming Fundamentals

2.3

Producing Robust Programs

2.4

Boolean Logic

2.5

Programming Languages & IDEs

Practice questions on Strings

Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.

  1. 1
    What is concatenation?Multiple choice
  2. 2
  3. 3
  4. 4
  5. 5
Answer all questions on Strings

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium