CS110A Week 11 Day 2 lesson on Thursday 10/29/2026
Watch on YouTube →
Overview
Indika Walimuni demonstrates how to extend California population plots with Matplotlib-style subplot layouts, then reviews Python Chapter 8 topics including modules, pseudorandom numbers, list aliasing, type conversion, and f-strings. The lesson also assigns exercises on phone-number formatting, bus capacity, weekday calculation, and anagrams, previews branching, and highlights nearby national-lab internship opportunities.
Key takeaways
- A subplot layout is controlled by its row, column, and plot-count arguments; adding a chart requires updating the layout and passing the matching data list into the plotting call.
- Python's random.randrange() includes its start, excludes its stop, and uses an optional step to restrict eligible values, while a fixed random seed reproduces the same pseudorandom sequence.
- Assigning a list to another variable creates an alias to the same object, whereas list[:] creates a separate shallow copy whose top-level elements can be changed independently.
- Python promotes integers to floats in mixed arithmetic, and int(), float(), and str() provide explicit conversions when the input value is compatible.
- F-strings evaluate expressions inside curly braces, but their formatted output is still a string; numeric format specifications can control precision and separators.
- The lesson's practice problems connect introductory Python techniques to practical tasks, including extracting phone-number digits, calculating 40-seat bus capacity, finding weekdays with a seven-day pattern, and checking anagrams without loops.
Chapters
- Indika Walimuni announces a 12 to 1 talk about internship programs at SLAC National Accelerator Laboratory near Stanford.
- Students are encouraged to attend and learn about opportunities connected to the lab.
- Students should open the linked notebook and choose File, then Save a copy in Drive.
- The class will work from individual copies of the California population assignment.
- The notebook prints year, total population, density rank, and population density as lists.
- The plotting code uses subplot rows, columns, and plot counts to arrange charts.
- Indika supplies most of the library code, asking students to recognize its pattern and extend it rather than learn the entire plotting library.
- The first plotting function is changed to three columns so it can display three plots in one row.
- The new chart uses density rank as its data and blue star markers.
- The code must pass density rank both to the plotting function and to the plot call; omitting an expected argument causes a type error.
- The class interprets the declining density-rank chart as evidence that California's population growth lagged other states.
- Indika connects population changes to congressional apportionment and discusses California losing two House seats after the 2020 census.
- The discussion compares California's losses with population and seat gains in states such as Texas and Florida.
- A second plotting function arranges charts in one column, with one plot per row.
- Students increase the plot count from two to three while keeping the column count at one.
- The resulting charts show density rank and a plateauing trend in California's population.
- Python modules must be imported before their functions are called, as shown with the square-root calculation for 49.
- The built-in dir() function lists attributes available in a module or class.
- The help() function can provide details about a function discovered with dir().
- The class uses math.pow() to raise the expression H minus I to the third power.
- An initial mistake using H plus I is corrected to match the problem's subtraction.
- The exercise reinforces module function calls through dot notation, such as math.pow().
- The random module includes functions such as random(), choice(), and Gaussian-distribution tools.
- Examples of randomness include dice rolls, coin flips, and variation in population measurements.
- Computing applications include password generation, cryptography, simulations, and probabilistic stock-market analysis.
- random.randrange(start, stop, step) selects values from a stepped sequence.
- The start value is included and the stop value is excluded, matching Python's range convention.
- A step of 10 produces values separated by tens, while the default step of 1 allows consecutive integers.
- Computers are deterministic, so Python's random module generates pseudorandom values with an algorithm rather than pure randomness.
- The Mersenne Twister algorithm produces a repeatable sequence when initialized with the same seed.
- Changing a seed from 15 to 16 changes the sequence, but rerunning with the same seed reproduces it.
- A fixed seed causes the random-number generator to repeat the same sequence on each run.
- Indika explains that Python initializes the generator automatically when no explicit seed is supplied.
- The changing initialization produces different sequences across runs, which is useful for simulations and games.
- Assigning one list variable to another copies the reference, so both names point to the same list.
- Changing an element through one alias also changes what the other variable displays.
- A full slice, list[:], creates a new list containing the original items and avoids this reference-sharing behavior.
- Python promotes an integer to a float in mixed arithmetic, so 1 + 3.0 produces a float.
- The int(), float(), and str() functions convert compatible values to the requested type.
- Calling type() verifies the result, such as converting the string "45" into integer 45.
- An f-string places f before its opening quote and uses curly braces for variables or expressions.
- Expressions inside braces are evaluated, so an expression such as 2 ** 2 displays as 4.
- Format specifications control numeric output, including fixed-point precision and comma grouping; formatted output is a string.
- A short exercise inserts color1 and color2 into an f-string using curly-brace placeholders.
- The phone-number formatter receives an integer and must display it in a grouped format such as 800-555-1212.
- Because the input is an integer, students should extract digit groups with integer division and modulo rather than string split().
- Indika asks students to read the assignment's instructional resources and linked lecture recordings.
- For the wedding-bus problem, each bus holds 40 passengers; students calculate the number of buses and unused seats.
- For the weekday-number problem, a spreadsheet of dates and weekdays can reveal the repeating seven-day pattern before writing the concise solution.
- The anagram function checks whether two words contain the same letters, such as silent and listen, and the assignment prohibits loops.
- Students should follow inline instructions, use the supplied tests, and add their name and LMS ID as code comments.
- Chapter 9 on if and else branching begins the following week and is expected to take about three class days.
- Indika recommends nearby national-lab internships, noting community-college eligibility, a GPA of at least 3.0, two recommendation letters, and four short essays.
- The class is told that the internship application process discussed does not involve coding interviews.
- A campus-approved UC Davis research survey for Latino students who use public transportation offers a $25 incentive for a survey and a 10 to 20 minute interview.
Transcript excerpt
0:00 Uh so this is the uh remainder reminder sorry um about the meeting uh Cody you should also go if you can the this meet like uh this one um I emailed you as well uh 12 to1 um I don't know where Harit brit building is though but I'm I'm thinking to go u because this is a SLAC slack National Lab. So it's down at Stanford. Um they are coming to give you guys a talk on their internships programs. I had a one student uh uh one of the TA in the past going into uh Slack. Yeah. She's now I think getting a second
0:50 internship in the same she's now at UCLA. Um so um she she probably get it. she actually have contacts now in the lab. So for the second time um okay guys so let's uh so we're going to solve that um the CA population problem right so basically um you click on this link you will get to this one right and then here's what you should do right so click over here file and then um save a copy in drive. Okay. So, save a copy in drive. That's what you should do. Okay. Save a copy in drive and then um it's it
1:43 will create a copy that it's a copy of and then then basically um you work it on. Okay. So, I'm going to copy paste the um the problems. I think I copied it already. I'm going to what I'm going to do is I'm going to go down at the bottom and then that's it. Yeah, I think um text and I'm going to actually make it go up and over here I'm going to Yes, this is the problem statement. Okay. All right.
2:30 Okay. So, uh the first thing uh
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.