Save this video free

CS 238 Week 4 Lecture

James Andro-Vasko · 19:00 · Watch on YouTube

Part of University of Nevada, Las Vegas CS 238. See all 9 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.

Overview

James Andro-Vasko introduces Python inheritance through a Square base class and a Cube subclass, showing how a subclass can reuse inherited methods, override get_area(), and add get_volume(). He demonstrates super() for calling the base class’s get_area() and __init__(), while using a cube’s side length and depth to compute its surface area and volume.

Key takeaways

Chapters

0:00 Square and Cube: Reusing Base-Class Behavior
6:00 Override Cube.get_area() with super()
11:00 Add Cube Volume and Initialize the Base Class

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

Transcript excerpt

0:00 Hello CS238. Uh for this week, week four, we're going to be talking about inheritance in Python. Now, inheritance is a pretty important um objectoriented design principle. It's basically the idea is you have one base class and you can use that base class to create multiple classes and it helps. So the purpose of inheritance is that you can reuse code without having to copy and paste. Um, of course, it makes your code a bit more flexible, easier to um, maintain it as well. And there are some uses of it, especially in C and Java. Um, in my experience, I've used it where if I had to do some type of uh, graphic interface, uh, there were certain base classes which has several functions implemented and of course you have to

0:48 simply use that and extend the class and so forth to be able to customize this uh, UI design. Now, of course, in certain languages, functional programming can also be used to implement um this sort of um UI design, but when I did content in Java in the past, we would use inheritance to customize some of the UI features and components. So, let's go ahead and now um sort of go through the example we have here for the class square. So, in this class square, well, you know, it's pretty self-explanatory. We have our constructor and we can see here we have an instance variable side. I used sort of double underscores to kind of give us this um illusion of a

1:36 private member in our square class. So side can't be used in main but of course we have these functions get perimeter and get area which are allowed to essentially look at the side variable and perform various calculations. Of course, we can do getters and setters as

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, James Andro-Vasko.

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.