Save this video free

CS 238 Week 2 Lecture

James Andro-Vasko · 40:27 · 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 object-oriented Python by building a Clock class with an __init__ constructor, instance fields, getters, setters, and a standalone function that accepts a Clock object. The examples explain how self identifies the instance, how setters can normalize hours and minutes with modulo arithmetic, and how assigning one variable to another makes both names refer to the same object.

Key takeaways

Chapters

0:00 Why Python Classes Encapsulate Reusable Data Types
1:27 Defining Clock and Adding an Instance Field
5:04 Initializing Clock Fields with __init__
8:26 Parameterized Constructors and Default Clock Values
16:05 Double-Underscore Fields and Getter Methods
22:34 Setter Methods Normalize Clock Values
33:13 Assigning Clock Variables Creates an Alias
35:24 Passing a Clock Instance to a Standalone Function

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

Transcript excerpt

0:00 Hello CS238 class. This is Jimmy Andro Vasco. I will be um instructing this course for the semester and um I have a series of these weekly short videos I will do to cover various topics in this course. So in this CS 238 course, we're going to be doing objectoriented Python. And um I'm more of a C++, C, Java person. In those languages, it's very important to create classes because it allows you to um create data structures and data types which can be used in all different types of applications. And the benefit of it is is that if somebody's using a custom or using a data type, it allows them to use it in their program without really exposing too much of the actual implementation details of the

0:48 object to make it very easy to kind of plug and play in different applications. So C++ with maps, uh, vectors, even string types, it has this sort of given to you and you don't have to really know all the details. As long as you know how to use those custom types, you're okay. And in Python with that numpy, it's a module, but within the module, there are classes within it which really help implement this entire dynamic array structure without really having to have you really mess with the actual inner implementation of that class. So that's sort of the purpose of classes. So let's go ahead and first begin with our simple uh test class we will write here called um clock class.

1:36 Okay, so before I write any code, I'm going to just say I'm using Atom editor to write my Python code. I have um on my Windows 11 machine, I have a WSL terminal. This is basically a Linux terminal I can use on Windows. So for

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.