← Cambridge IGCSE

Strings: Cambridge IGCSE practice

Slicing, length, case and characters. 16 questions in the style of the Cambridge IGCSE exam.

Sample questions

What is the value of `len("Hello world")`?

  1. 10
  2. 11
  3. 12
  4. 2

What does this program print?

s = "banana"
count = 0
for ch in s:
    if ch == "a":
        count += 1
print(count)
print("nan" in s)

If `s = "computer"`, what is `s[2:5]`?

  1. "omp"
  2. "mpu"
  3. "mput"
  4. "ompu"