Strings: IB Computer Science practice
Slicing, length, case and characters. 15 questions in the style of the IB Computer Science exam.
Sample questions
What is the value of `len("Hello world")`?
- 10
- 11
- 12
- 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]`?
- "omp"
- "mpu"
- "mput"
- "ompu"