Python (Fall 2026) Module 9-7: S9 Explanation
Overview
Bill Moseley explains the S9 Python sandbox assignment: build an algorithm that ranks three passages about the phases of the Moon, written at fourth-grade, 10th-grade, and PhD levels. He suggests measurable features (including average word length, unique-word count, sentence length, and punctuation) and frames the task as practice turning a problem into a coded solution.
Key takeaways
- A text-sophistication algorithm can rank the three Moon-phase passages without identifying exact grade levels; an ordered numeric score is sufficient.
- Average word length and sentence length offer measurable clues for distinguishing simpler fourth-grade writing from more advanced prose.
- Vocabulary variety can be estimated by splitting text into words, converting the list to a set, and counting the unique entries.
- Punctuation frequency, including commas and semicolons, can serve as another feature in comparing the fourth-grade, 10th-grade, and PhD-level passages.
- The S9 assignment practices the core programming workflow: identify measurable properties of a problem, design an algorithm, and implement a solution in code.
Chapters
- The S9 sandbox task compares three passages about the phases of the Moon, written at fourth-grade, 10th-grade, and PhD levels.
- The algorithm should order the passages by sophistication; it can return scores such as 100, 150, and 250 instead of grade labels.
- Possible indicators include average word length, sentence length, and vocabulary variety; more advanced writing may use longer words and more varied vocabulary.
- Moseley also suggests comparing punctuation, noting that commas and semicolons may occur more often in the PhD-level passage.
- To count distinct words, split a passage into individual words, convert the words to a set to remove duplicates, and count the set's elements.
- The measured features can contribute to a text-sophistication score that indicates which of the three sample passages is more advanced.
- Moseley presents the assignment as practice decomposing a problem and designing a coded solution, a recurring task in programming.
- As the class approaches the midterm, he describes the exercise as a way to assess students' comfort with programming and prepare for continued algorithmic thinking.
Transcript excerpt
0:01 S9 for the sandbox assignment. It's pretty straightforward. But I think it is useful, which is why I assigned it in the first place. Be kind of stupid if I assigned things that weren't useful. But what I have here for S9 is kind of an interesting problem, I think. I've created three very similar passages of text written at different grade levels. I have a fourth grade level, a 10th grade level, and a PhD level. They're all about the same thing. They're all about the phases of the moon. And what I want you to do is I want you to create an algorithm that will rate these. Now, that doesn't have to say fourth grade, 10th grade, and PhD level. Your algorithm could spit out a number, say like 100, 150, 250 or something like that,
0:57 just some indication that it recognizes that this one is more advanced than this one, and this one is more advanced than this one. So what you have to do is you have to think about things that you can measure in those texts that might tell you if a fourth grader or a PhD is doing the writing. So, what you might expect from a fourth grader is maybe shorter words, simpler sentences, shorter sentences. PhD is going to probably have more word variety. So, a, a, a larger number of different words. You're going to expect probably more uses of like commas and semicolons in a PhD over a fourth grader. So, those are all things. Average word length, word variety,
1:49 all of those things you can, you can measure by breaking up these sentences and analyzing the words. You can measure the average length. You can measure how many different words there are by removing the duplicates and then counting. Right? So, if I, if I break these down into individual
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.