Back to the Introduction to Computer Science outline The Course Maker
Introduction to Computer Science outline
Week 11 · Quiz

Week 11 — Quiz (auto-graded) · Strings in Depth & Text Processing

Introduction to Computer Science · CSCI 1101 Fall 2026 · Prof. Okafor Fictional sample

Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Objective tested: Objective 7 — string methods; immutability (methods return a new string); .split()/.join(); simple text algorithms.
Points: 10 (1 each) · Assignment group: Quizzes (10% of grade) · Due: end of Module 11.

This is the human-readable quiz with its vetted answer key and feedback. The import-ready Classic QTI is in F-quiz-week-11-qti.xml (generated by the shared validated script — parses with 10 items, every single-answer item exactly one correct). Execution gate: PASS — every "what does this print?" key below was produced by actually running the code in Python, not hand-traced. The Canvas placement block is at the bottom of this file.


Blueprint

# Type Concept Objective
1 Multiple choice Predict the output.upper() returns an uppercase string 7
2 Multiple choice Predict the output — immutability (s.upper() doesn't change s) 7
3 Multiple choice Predict the output.split() returns a list 7
4 Multiple choice Predict the output.join() returns a string 7
5 Multiple answer True statements about string methods & immutability 7
6 Matching Method → run-verified result 7
7 Multiple choice Debugging — forgot to reassign the method result 7
8 True / False "A string method changes the original string" misconception 7
9 Multiple choice Text algorithm — count words with len(s.split()) 7
10 Multiple choice Predict the output — reverse a string with s[::-1] 7

No trick questions; distractors are plausible mis-traces (expecting a method to mutate in place, .split() returning a string, .replace changing only the first match, .find() returning True/False).


Questions, key, and feedback

Q1 (MC). What does this program print?

print("python".upper())
  • A. python
  • B. PYTHON
  • C. Python
  • D. an error
    Feedback: .upper() returns a new string with every letter uppercased, so the output is PYTHON. (Run-verified: PYTHON.)

Q2 (MC). What does this program print?

word = "cat"
word.upper()
print(word)
  • A. CAT
  • B. cat
  • C. Cat
  • D. an error
    Feedback: Strings are immutable. word.upper() builds a new string "CAT" and returns it, but that result is thrown awayword itself is never changed. So print(word) shows cat. To keep the change you'd write word = word.upper(). (Run-verified: cat.)

Q3 (MC). What does this program print?

print("red,green,blue".split(","))
  • A. red green blue
  • B. 'red,green,blue'
  • C. ['red', 'green', 'blue']
  • D. red,green,blue
    Feedback: .split(",") breaks the string at each comma and returns a list of the pieces — note the square brackets and quotes. (Run-verified: ['red', 'green', 'blue']. .split() returns a list, not a string.)

Q4 (MC). What does this program print?

print("-".join(["a", "b", "c"]))
  • A. ['a', 'b', 'c']
  • B. a-b-c
  • C. abc
  • D. a, b, c
    Feedback: .join() glues the list items into one string, putting the separator ("-") between each pair. So you get a-b-c. (.join() is the inverse of .split() — it returns a string. Run-verified: a-b-c.)

Q5 (Multiple answer — select all that apply). Which of the following statements are true?
- A. "banana".count("a") returns 3
- B. A string method returns a new string and leaves the original unchanged
- C. .split() returns a string
- D. .replace("a", "o") replaces every a, not just the first
- E. "hello".find("z") returns True
Feedback: .count("a") on "banana" is 3 (A); methods return a new string and don't change the original (B); .replace changes all matches (D). C is false.split() returns a list. E is false.find() returns an index or -1 (here -1), never True/False. (Run-verified: 3; -1.)

Q6 (Matching). Match each method call to its run-verified result.
| Method call | Correct result |
|---|---|
| "HELLO".lower() | hello |
| " hi ".strip() | hi |
| "mississippi".count("s") | 4 |
| "hello".startswith("he") | True |
Feedback: .lower()hello; .strip() trims both ends → hi; .count("s") on "mississippi"4; .startswith("he")True. (All run-verified.)

Q7 (MC). This program is supposed to print [bob] (no spaces), but it prints [ bob ] instead:

name = "  bob  "
name.strip()
print("[" + name + "]")

What is wrong, and how do you fix it?
- A. .strip() is the wrong method; use .replace()
- B. The result of name.strip() was never reassigned; fix it with name = name.strip()
- C. Strings can't be stripped; you must use a loop
- D. Nothing is wrong; it already prints [bob]
Feedback: .strip() returns a new, trimmed string — but the program discards it. Because strings are immutable, name is unchanged. The fix is to reassign: name = name.strip(), after which it prints [bob]. (Run-verified: the broken version prints [ bob ]; the fixed version prints [bob].)

Q8 (True / False). "In Python, calling s.upper() changes the string stored in s."
- True
- False
Feedback: False. Strings are immutable: s.upper() returns a new uppercase string and leaves s exactly as it was. To keep the result you must reassign (s = s.upper()). (Run-verified: after s = "Hello"; s.upper(), s is still Hello.)

Q9 (MC). This program counts the words in a sentence. What does it print?

sentence = "the quick brown fox"
print(len(sentence.split()))
  • A. 1
  • B. 3
  • C. 4
  • D. 19
    Feedback: .split() turns the sentence into the list ['the', 'quick', 'brown', 'fox'], and len(...) counts its 4 items. So the word count is 4. (Run-verified: 4. 19 would be the number of characters, len(sentence).)

Q10 (MC). What does this program print?

print("stop"[::-1])
  • A. stop
  • B. pots
  • C. STOP
  • D. an error
    Feedback: The slice [::-1] returns a new string that is the original reversed, so "stop" becomes pots. (Run-verified: pots. The original string is unchanged — slicing, like every string operation, builds a new string.)

Answer key (quick reference)

Q Answer
1 B (PYTHON)
2 B (cat)
3 C (['red', 'green', 'blue'])
4 B (a-b-c)
5 A, B, D
6 lower→hello / strip→hi / count("s")→4 / startswith→True
7 B
8 False
9 C (4)
10 B (pots)

Quality gate (self-checked): each single-answer item has exactly one correct option; the multiple-answer item keys A, B, D (and requires C and E unselected); the matching item pairs four method calls to four distinct results. Execution gate: PASS — the keys for the predict-the-output items (Q1 PYTHON; Q2 cat; Q3 ['red', 'green', 'blue']; Q4 a-b-c; Q9 4; Q10 pots), the matching results (Q6 hello/hi/4/True), and the debugging item (Q7 [bob] after the fix) were each produced by running the code in Python, not hand-traced. Distractors are plausible mis-traces (Q2 CAT = expecting mutation; Q3 red green blue = treating .split() as returning a string; Q9 19 = counting characters not words).


Item-bank entries (for variants + the midterm/final)

All ten items are tagged course=CSCI1101 · week=11 · objective=7 · topic=strings-and-text-processing and deposited in Item Bank: Week 11 — Strings & Text Processing. The final (Week 16) and the per-term variant updates draw fresh items from this bank. (Tags: q1 upper, q2 immutability, q3 split-list, q4 join-string, q5 true-statements, q6 method-match, q7 debug-reassign, q8 immutable-tf, q9 count-words, q10 reverse-slice.)

Canvas placement block

canvas_object   = Quizzes::Quiz
title           = "Week 11 Quiz — Strings in Depth & Text Processing"
assignment_group = "Quizzes"
points_possible = 10
grading_type    = points
due_offset_days = 5        # 5 days after module start (Sun Nov 15)
published       = true
shuffle_answers = true
ai_permitted    = false    # AI is not permitted on quizzes
provenance      = "~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com"
This is the human-readable quiz with its vetted answer key and rationale. The import-ready Classic-QTI version (F-quiz-week-11-qti.xml) ships inside the course's .imscc package — it lands in the Canvas gradebook on import.

~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com