CS110A Week 7 Day 2 lesson on 10/01/2026
Watch on YouTube →
Overview
Indika Walimuni teaches CS110A students to design Python functions before coding, using a turtle-based circle function to practice parameters, docstrings, and translating a plan into actions. The lesson also covers function stubs, printing versus returning values, math-module expressions, unit-conversion exercises, and a turtle smiley-face challenge, alongside assignment guidance and a brief discussion of research as curiosity put into action.
Key takeaways
- A turtle circle function can reuse turtle.circle(radius) while handling setup separately: lift the pen, move to the requested coordinates, lower the pen, turn by the starting angle, and draw.
- The public interface of a Python function—its definition and docstring—should communicate the function’s purpose and parameters without requiring readers to inspect its body.
- pass is useful for a temporary function stub, but an unfinished function may silently do nothing and yield None where a completed implementation should return a value.
- A conversion function should return its calculation, such as feet multiplied by a conversion factor; printing is appropriate when the task is output rather than producing a reusable value.
- Even spacing around a full circle uses 360 divided by the number of parts, so six equally spaced flower petals require a 60-degree turn.
- For a driving-cost calculation, miles divided by miles per gallon gives gallons consumed; multiplying gallons by dollars per gallon gives total cost.
Chapters
- Indika corrects an agenda copy-paste error and identifies the smiley-face drawing as a later activity.
- He copies the circle-function prompt into the coding workspace and fixes formatting and alignment problems before starting.
- The prompt asks for a Python function that draws a circle using a radius, starting angle, starting location, and color.
- Indika recommends turning prompt wording into expressive variable names, including start_x and start_y for the coordinate pair.
- The function specializes Python’s existing turtle circle method rather than recreating circle drawing from scratch.
- The turtle begins at the origin facing east; it must lift its pen before moving to the requested starting location.
- The plan moves the turtle to the coordinate pair, lowers the pen, turns left by the starting angle, and draws the circle.
- Drawing the movement sequence first helps explain why pen-up and pen-down actions matter.
- The implementation uses turtle methods such as up(), goto(), down(), and left(), followed by circle(radius).
- The function’s public interface consists of its definition and docstring; together they should explain its purpose and inputs.
- The docstring describes drawing a circle of a given radius, starting angle, location, and color.
- The class tests a circle with radius 50, a starting angle, coordinates, and a color argument.
- Syntax and name errors lead to checking the code and importing the turtle module before rerunning it.
- The successful drawing shows the turtle moving to its location, turning, and then drawing the circle.
- Indika describes reusing the circle function to draw a flower with repeated petals at different angles.
- A proposed flower has eight petals and a separate center circle, which can be drawn by changing the circle’s location.
- The class postpones the full flower implementation to save time.
- A function stub can contain pass when its intended behavior is known but its code is not ready.
- Calling a function whose body contains pass does not perform the planned work or raise an error.
- An incomplete calculation can consequently produce None when a return value has not been implemented.
- The class defines print_price with grocery_name and grocery_price parameters.
- The function prints a formatted cost line rather than returning a value.
- An autograder’s whitespace feedback reveals extra spaces; removing them makes the output match.
- A course video frames research as starting with curiosity, formalizing a question, choosing an approach, and generating new knowledge.
- Research is presented as useful beyond academia, including software engineering and other careers where people investigate improvements.
- The video connects curiosity to a larger personal value proposition: what motivates someone, what value they offer, and what employers seek.
- The math module provides pi as a value, accessed with dot notation as math.pi rather than called with parentheses.
- A cylinder surface-area example combines mathematical operations, math.pi, and function calls.
- Python function calls are expressions; print is a function call that returns None, even though it is often casually called a print statement.
- Students complete convert_to_meters with a feet parameter.
- The function returns the number of feet multiplied by the feet-to-meters conversion factor.
- The completed function passes the exercise check.
- The lab function takes hours, minutes, and seconds as three parameters and calculates total seconds.
- Students are directed to read the instructions and replace the designated function call in the main program.
- A training exercise precedes the actual lab, which follows the class’s established function format.
- For an individual discussion, students choose two Python built-in functions and demonstrate them with examples.
- The instructions link to Python’s built-in function documentation and a Compiler Explorer code template.
- Students can link or embed their code and add comments to make the examples useful to classmates.
- The assignment uses a general conversion function with an amount, starting unit, ending unit, and conversion factor.
- Examples include inches to meters and kilograms to grams or pounds.
- Students enter their name and LMS ID, complete the planning section, implement the function, and call it in the provided area.
- Indika says the midterm is a project rather than an exam; students will choose a topic and medium and have nearly three weeks to complete it.
- The smiley-face exercise asks students to draw a circular outline, two eyes, a nose, and a mouth using turtle graphics.
- For a simple first version, students can use a line for the nose and a horizontal line for the mouth.
- Evenly spaced petals use a turning angle of 360 degrees divided by the number of petals: six petals require 60 degrees.
- For filled turtle shapes, set the fill color, call begin_fill(), draw the shape, and call end_fill().
- The instructor recommends placing the drawing code inside a function such as draw_flower and passing the color as a parameter.
- A student reports that five expected questions are missing from the smiley-face assignment; Indika identifies an editing mistake and adds them.
- Students are asked to refresh the discussion page before submitting so the corrected questions appear.
- Indika advises against using loops before the class has learned them and recommends reporting course-material errors in the general Q&A forum.
- The driving-cost calculation uses miles driven, gas mileage in miles per gallon, and gas price in dollars per gallon.
- Compute gallons used by dividing miles driven by miles per gallon, then multiply by the price per gallon to get the cost.
- Indika confirms that a student’s planned calculation follows the correct process and ends class by offering help with remaining questions.
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.