Save this video free

Python (Fall 2026) Module 14-12: A14 Explanation Part 2

Bill Moseley, Ph.D. - Computer Science Educator · 10:08 · Watch on YouTube

Part of Bakersfield College COMP B10. See all 22 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Python (Fall 2026) Module 14-12: A14 Explanation Part 2 Watch on YouTube →

Overview

Bill Moseley demonstrates how to refactor Python fruit-management code by moving list-adding and list-removing logic into `addFruit` and `rmFruit` functions that accept and return the modified list. He then recommends practicing by retyping or reconstructing the code, reverse-engineering examples, and checking the assignment requirements in Canvas before submission.

Key takeaways

Chapters

0:00 Refactoring Fruit Addition and Removal into Python Functions
4:44 Practice Rebuilding the Assignment Instead of Copying It
8:39 Validate Python Assignment Requirements Before Submission

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:00 Now, one thing that this doesn't currently  do is, it doesn't have functions for adding and removing the fruit. All it does is  right here in the middle of these menus, do the adding. So, I'm going to actually  show you how I would make the move from just these four lines of code here  to doing something using a function. So, I'm going to roll up the class here so I  don't have that staring at me. There we go. And right below that, I'm going to create  a function. So, def. So, I'm at the same, at the main level of my program, not inside that  class. I am creating a function called addFruit. And I'm going to give that the fruit  list. I'm going to give it a list as an,

1:02 as a model, and I'm going to return that list after I've modified it. So I want to add  a fruit to that list. So how do I do that? Well, here's my main code here, these four lines.  So, I'm going to cut those from there, and I'm going to come up here and I'm going to put  those four lines of code right inside my function. But instead of liFruit, I'm going  to use this internal list. So, it's this list that I pass in. I'm going  to append to it and then send it back out. Now,

2:03 there we go. That's why that was giving me a  little back talk. All right. So I put that in. I ask the questions, and then I create an instance  of the fruit, and then I return it. Is it really that simple? Well, almost. Now, I just need to  implement that function. So, what do I do? I'm gonna say addFruit, and I'm going to give it the  fruit list as a method, or as a, argument. Sorry.

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.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.