Concatenate strings and explain + on strings vs numbers
Use len() to determine string length
Extract substrings using Python slicing and AP SUBSTRING
Avoid common string type-error traps
📈
Exam Impact: Strings appear in both MCQ code-tracing and Create Task written responses about program purpose.
💡 Why This Matters
Why does 5+3=8 but '5'+'3'='53'? Understanding that strings are sequences of characters -- not numbers -- is the key insight behind every AP CSP string question.
String Basics
A string is a sequence of characters in quotes. Strings are immutable -- you cannot change a character in place; you create a new string.
first = "Alice"
last = "Smith"
full = first + " " + last
n = len(full) # 11
sub = full[0:5] # "Alice"
first <- "Alice"
last <- "Smith"
full <- CONCAT(first," ",last)
n <- LEN(full)
sub <- SUBSTRING(full,1,5)
Slicing Trap: Python vs AP Pseudocode
Python s[start:end] -- 0-based, end is exclusive. AP SUBSTRING(s, start, length) -- 1-based, third argument is length not end index.
Exam trap: These two conventions are different. Always check which the problem uses.
Practice Problems
🔎 Practice MCQ
What is the value of "score" + str(99)?
🔎 Practice MCQ
word = "Python". Which evaluates to "Pyt"? I. word[0:3] II. word[1:3] III. SUBSTRING(word,1,3)
⚠️ Predict your answer BEFORE clicking.
🔎 Practice MCQ
A programmer writes result = "Total: " + 42. What is WRONG?
⚠️ Predict your answer BEFORE clicking.
🎮 Game
String Value Tracer
Predict the output of each string expression. 8 questions.
0
Correct
1/8
Question
0
Streak 🔥
🤔 Evaluate:
0/8
correct
💻 Python Code Editor
Practice Problems
Write Python and check your answer. Paste into Replit for complex programs.
Problem 1 of 3
Print the first 3 characters of "Computer". Expected: Com
Hint: print(word[0:3])
Problem 2 of 3
Concatenate "AP" and "CSP" with a space between them. Expected: AP CSP
Hint: print(a + " " + b)
Problem 3 of 3
Spot the error: should print the length of "hello world" (11) but crashes. msg = "hello world" print(length(msg))
Hint: Python's function is len(), not length(). print(len(msg))
Frequently Asked Questions
s[0:5] gives exactly 5 characters (indices 0-4). The count is always end-start. Adjacent slices never overlap: s[0:3] and s[3:6] cover different characters with no gap.
AP SUBSTRING(s, start, length) uses 1-based indexing and takes a length as the third argument. Python s[start:end] uses 0-based indexing and the end is exclusive. Always check which convention the problem uses.
Yes. 'hello' == 'Hello' is false because case matters. AP pseudocode uses = for comparison inside conditions.
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed.
Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Typically responds within 24 hours
✓
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.