Homework: Text Statistics
作业: 文本统计
Six functions — five tiny helpers and one assembler. The shape of every text-processing pipeline.
The six functions
char_count(text)— non-whitespace charsword_count(text)— whitespace-split wordslongest_word(words)— first on tiesunique_word_count(words)— distinct (uselen(set(words)))starts_with_count(words, prefix)— filter comprehensiontext_stats(text)— assembles dict, calls the helpers
The orchestrator
Python · runnable
One-line idioms used in the helpers
Python · runnable
Acceptance criteria
- All 10 tests pass
text_statscalls at least 3 of the 4 helpers- All helpers handle empty input