Note AcademyNote Academy

Computer Science · May / June 2024 · Paper 1 TZ1 HL · Question 16

Adapt for 2027Substring manipulation, trace tables and validation loops are on the course (B2.1, B2.3) but the answers should be written in Python or Java, not IB pseudocode.

IBCS

As printed in the paper

The question as text

16. String manipulation is a useful programming concept. Strings are zero-indexed: the index of a string’s first character is 0, and the index of a string’s last character is the length of the string minus 1. A set of string manipulation sub-programs is given in Figure 4. Figure 4: String manipulation sub-programs Name Description Example subString(X, Y, Z) Returns a new string that is a substring of X. The length of the substring is Z and the substring begins with the character at index Y. subString("Test", 2, 1) returns "s" lenString(X) Returns the length of the string X. lenString("Test") returns 4 revString(R) Returns a copy of the string R in reverse order. revString("Test") returns "tseT" joinString(S, J) Returns a new string by concatenating the strings S and J. joinString("Join", "Test") returns "JoinTest"

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme
  • 16(a)[2]

  • 16(b)[5]

  • 16(c)[8]

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.