CS110A Week 10 Day 2 lesson on 10/22/2026
Watch on YouTube →
Overview
Indika Walimuni teaches Python through two practical threads: calculating the minimum number of desks with ceiling division, and building string skills needed to process text. The lesson covers default parameters, docstrings, the optimized formula `(students + capacity - 1) // capacity`, escape sequences and raw strings, Unicode code points with `ord()` and `chr()`, string indexing and concatenation, then introduces a street-address task modeled on postal OCR and ZIP-code sorting.
Key takeaways
- For a positive desk capacity, the minimum desk count can be computed without importing `math` as `(students + capacity - 1) // capacity`, which implements ceiling division with integers.
- A Python default parameter such as `desk_capacity=4` allows callers to omit that argument while preserving a documented fallback.
- Backslashes introduce escape sequences in ordinary Python strings; an `r` prefix is a convenient way to preserve Windows-path backslashes literally.
- Python’s `ord()` and `chr()` expose the relationship between single characters and Unicode code points, which supports numeric comparisons and lexicographical string ordering.
- Python strings are ordered sequences indexed from zero, with negative indexes counting backward; `len()` gives the length and the last positive index is `len(string) - 1`.
- Strings can be concatenated with `+`, but numbers must first be converted with `str()`; `print()` output separators can be customized with the `sep` keyword.
Chapters
- The opening problem asks for the minimum number of desks needed to seat a class.
- The solution must account for desk capacity, which defaults to four students.
- The inputs are the total number of students and the capacity of each desk.
- The output is the minimum number of desks required, with capacity four as the default.
- For 27 students and capacity four, seven desks are needed because six desks leave three students without seats.
- The examples show that ordinary floor division is insufficient whenever the last desk is only partly occupied.
- Dividing 27 by four gives a floor-division result of six, but the required desk count is seven.
- The first proposed approach uses `math.ceil()` to round the quotient up to the next whole desk.
- The plan defines a function named `find_minimum_desks` with student count and desk capacity as parameters.
- Setting the capacity parameter to four lets Python use four when a caller omits that argument.
- The docstring should describe the function’s result and refer clearly to its inputs.
- The first implementation imports `math` and returns `math.ceil(total_students / desk_capacity)`.
- Tests include 37 students at capacity five, which requires eight desks, and 37 at the default capacity four, which requires ten.
- The import-free integer formula is `(total_students + desk_capacity - 1) // desk_capacity`; for capacity four, it adds three before floor division.
- The optimized function is compared with the `math.ceil()` version using 23 students at capacities five and four.
- Testing one student confirms that both approaches return one desk, and examples are used to generalize the pattern.
- Calling `dir(math)` lists the attributes available in the imported `math` module, including `ceil`.
- Calling `help(math.ceil)` displays the function’s documentation, providing a reference even without internet access.
- Unicode assigns numeric code points to characters, extending the earlier ASCII idea to scripts beyond English.
- Python represents strings as text while the underlying computer processes numeric values in binary.
- A quote character inside a string can end the literal unexpectedly, as shown with a Muhammad Ali quote containing quotation marks.
- A backslash escapes an inner quote so it is printed as text rather than treated as the string delimiter.
- Python’s syntax error can point to a symptom, such as an unterminated string, without explaining the underlying quoting conflict.
- A Mozilla explainer describes how Microsoft Internet Explorer held nearly 100% of the browser market by the late 1990s.
- Netscape open-sourced its browser code, allowing people to use, copy, modify, and remix it.
- The Mozilla community used open code and volunteer collaboration to build Firefox, which helped break Internet Explorer’s browser monopoly.
- The lesson demonstrates escaped single quotes, newlines, and tabs, including `\n` and `\t`.
- Windows paths contain backslashes, which can be cumbersome to escape individually in a long path.
- Prefixing a string literal with `r`, as in `r"..."`, creates a raw string that preserves backslashes for path text.
- Computers compare text through numeric character encodings rather than by human intuition about alphabetic order.
- The examples give Unicode values 48 for the digit `0` and 65 for capital `A`.
- Comparing strings character by character according to their encoded values is described as lexicographical ordering.
- Python’s built-in `ord('A')` returns 65, while `chr(65)` returns the character `A`.
- The functions accept a single character or an integer code point, respectively, and demonstrate the numeric basis of character comparisons.
- A coding exercise builds an output combining a drive letter such as `G` with a path containing backslashes.
- Adding an `r` prefix to the relevant string literal preserves the backslashes and produces the requested path output.
- The exercise illustrates how a raw string can avoid manually adding escape backslashes throughout a path.
- A string is introduced as an ordered sequence of characters, which makes individual letters accessible by position.
- For the string `Python`, positions are numbered from zero, so `py[2]` returns `t`.
- The word-count example motivates examining characters such as spaces within a string.
- For `Python`, `len(py)` is six, the final positive index is five, and negative indexing starts at `-1` for the final character.
- The square brackets perform indexing, and both left-to-right and right-to-left access are demonstrated.
- The plus operator concatenates strings, while `print()` uses a space separator by default and can change it with `sep=", "`.
- Python raises a type error when a number is added directly to a string; `str()` converts the number before concatenation.
- Students are directed to review Python string methods, including operations for counting and finding substrings, to prepare for the street-address problem.
- The postal example explains how optical character recognition turns handwritten addresses into text that software can use to identify ZIP codes and house numbers for mail sorting.
Transcript excerpt
0:00 Good morning, guys. Sorry about the delay. I got stuck at BART station. Yeah, so we're just starting. Okay, so the problem we are solving is this one, right? Um minimum desk. Um this is a much easier problem, okay? So and then and the good match is actually um the the clock face problem actually is a good match. Match and then we have several matches. Um >> [snorts] >> Okay. Um Okay, um I'm going to put over here.
0:58 This is our problem. All right. Okay, so what is the input in this problem? Yeah, total number of students and Yeah. Um So um Well, I think yeah, total number of students is one input.
1:44 And then you can see that there's a clue over here and just the one input, right? But and then you can see that if you um if you take a look at the problem statement again, um Let's see. No, um this one. Um There's a improvement, right? So, that also an input, right? The capacity, right? So, um All right, I'm going to add this one over here. Right? So, this is the idea to improve. Right? So, let's let's solve both of
2:33 them, right? So, the maximum number of students uh can be sit on uh the one days is actually also um um a variable an input, and then it's it should default to four. All right, so uh I would say total um number of students total students Okay. And then then um desk capacity Okay. And then there is default to um to four, okay?
3:23 All right. Okay. So, All right, so um So, we can start with the match. It's a good match. Um how do we how do we solve this problem? So, if we take
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
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, indika walimuni.