CS110A Week 7 Day 1 lesson on 09/29/2026
Overview
Indika Walimuni guides CS110A students through an equilateral-hexagon turtle program, using input analysis, a hand-drawn plan, and a Python function that accepts a turtle, side length, fill color, and coordinates. The lesson connects function parameters and return values to code reuse and readability, introduces a midterm project due near the end of October, and ends with a collaborative flower-drawing exercise and debugging help.
Key takeaways
- A regular hexagon's turtle turning angle is 60 degrees, computed as 360 divided by six sides; the turtle must lift its pen while moving to a supplied starting coordinate.
- Passing a single turtle object into a drawing function avoids repeatedly creating graphical objects and supports reuse across multiple shapes.
- Function parameters generalize behavior: a square function can use a size parameter instead of duplicating separate implementations for each side length.
- A function call can return a value used inside a larger expression, while printing is a separate operation that displays the result.
- A 100-sided polygon exposes the limits of manually repeated code, which motivates using loops to repeat movement and turning operations.
- The midterm project allows roughly four weeks and recommends practical or unfamiliar formats, including a GitHub Pages resume or a data-analysis report.
Chapters
- Walimuni asks students to refresh Canvas because the correct Trinket link has been added.
- The class begins an AMP-style analysis of an equilateral hexagon drawing problem.
- The problem inputs are side length as an integer, fill color as a string, and a point represented by integer x and y coordinates.
- The output is a filled equilateral hexagon drawn on a plane.
- Walimuni recommends working through sample inputs and outputs before coding, including sketching graphics problems.
- The turtle must first move from the origin to the supplied coordinate pair before drawing.
- For a six-sided regular polygon, the exterior turning angle is 360 degrees divided by 6, or 60 degrees.
- The turtle must lift its pen before moving to the requested starting point, then lower it to draw the sides.
- Walimuni writes the repeated forward-and-turn steps explicitly, noting that loops will later replace this repetition.
- The function takes a turtle, side length, fill color, and x and y locations as parameters.
- The implementation uses turtle up(), goto(x, y), down(), forward(), and left() operations.
- The docstring describes the drawing and its inputs, while the function name and docstring form its public interface.
- Passing one turtle object into the drawing function avoids recreating a graphical object for every shape.
- The first run exposes a missing turtle import, followed by a typo and indentation problems caused during code editing.
- Walimuni recommends copying code before refreshing Trinket because refreshing may risk losing unsaved work.
- The code includes integer and string values, a turtle object, function-call expressions, and an import statement.
- Writing a 100-sided polygon by hand would require roughly 200 repeated movement and turning lines.
- A loop is the future technique for generalizing polygon drawing by side count; the lesson identifies loops as a topic for a later week.
- The midterm is a project rather than an exam, with about four weeks to complete it and a stated maximum effort of roughly 10 hours.
- Students choose a topic and subtopic, or seek approval from Walimuni for a self-proposed project.
- Suggested subjects include computer hardware, data, the internet, privacy, security, and AI.
- Walimuni recommends trying a new format, such as a presentation, recorded talk, infographic, slideshow, poster, or concept map, rather than defaulting to an essay.
- A GitHub Pages resume project can build a practical software-development skill and produce a public portfolio artifact.
- A data-analysis report can combine a personally meaningful question, external data, visualization, and scientific-report writing.
- A Code.org lesson demonstrates how a square-drawing function can accept a size parameter instead of requiring separate functions for 50-pixel and 100-pixel sides.
- A parameter acts as a named placeholder, and the caller supplies a concrete value such as 63.
- Adding parameters for properties such as size or color reduces duplicated code and makes one function useful in more situations.
- Walimuni distinguishes inputs to a function from Python's input() function, which reads a value from the keyboard.
- Function inputs should generally be supplied through the parameter list, as with the hexagon's side length and coordinates.
- Python Tutor is recommended for tracing code; its green line marks the most recently executed statement and its red line marks the next one.
- Function definitions do not execute their bodies until a call occurs; execution enters the called function and proceeds through its body.
- A circle-area function can be called inside a pizza-calorie calculation, then return its value to the original call site.
- A function call can be part of a larger expression, such as multiplying a returned area value by another quantity.
- The class builds calculate_result with one parameter and a return value equal to 5.2 times that parameter.
- A function that returns a value is described as fruitful, while one that does not return a value is nonfruitful.
- The exercise distinguishes returning a result from printing it, and formats displayed output with an f-string.
- A descriptive function name and docstring let readers understand a hexagon-drawing function without inspecting every turtle command.
- Modular development reuses a rectangle function to build a more complex drawing.
- Calling a function repeatedly can replace hundreds of copied lines, such as code for eight rectangles.
- Students open a new AMP-style flower activity in Canvas and copy the provided starter material into an empty Trinket.
- The task is to define a circle function, reuse circles as petals, and create a flower.
- Walimuni directs students to consult turtle method documentation for built-in circle-drawing support.
- Students are asked to work in teams on the flower activity and locate it through the course modules if necessary.
- Walimuni explains that starting this week, students receive points for including a plan.
- The earlier hexagon extension offers two extra points for a creative pattern, including a honeycomb made from three hexagons or a flower-like arrangement.
- In a separate operator-demonstration exercise, the user number should arrive as a function parameter rather than being collected inside the function with input().
- For subtraction, the function should return the calculation, and the caller must provide the required positional argument.
- Printing the function call displays its returned result; adding a second parameter can generalize the example to subtract any two numbers.
- The completed example calls the subtraction function with a concrete number and wraps the call in print() to show the result.
- Walimuni suggests replacing the fixed subtracted value with a second parameter to make the function reusable for arbitrary pairs of numbers.
Transcript excerpt
0:00 All right, good morning guys. So this is our agenda today. So um we're going to first solve that uh problem which is um this one. Okay. All right. So me I think it's over here. Okay. All right. So, I'm going to copy paste the problem. Okay. But by the way guys, I added um you remember I was missing the the proper um the trinket link, right? So, I added
0:48 that. Okay. So, could you all refresh? If you haven't refreshed your canvas um today morning, please do that. Okay. So, I um change that. Okay. So, um All right. I'm going to do this. It's kind of goes to the end. All right. And uh this is ideas to change
1:37 improve. Okay, me turn off the slides. Okay. It's not that. Can you guys really read this? Or can I should I enlarge? Yes. Okay. How about now? It's good, right? Okay. So, um Okay. So, let's figure out the So, this is the uh amp step, right? So uh let's do the the rest of the understanding. Okay. So
2:27 uh inputs. Okay. So um what are the inputs here inputs? inputs. What are the inputs here? Well, we are solving the equilateral hex hexagon problem. Yeah. Side length, right? So, um and then then color, right? Fill color. Okay. So, and then also the point. So, all kind of recognized by the word
3:16 given, right? So, given means that's your input. Okay. So the the side length okay and and it also like you know at the same time try to think of okay what kind of a what type of a input is that? So this is actually the in like you know this is the integer right so like we can write int and then because it's a it's in
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, indika walimuni.