dude. the internet is crazy, I have been to the best universities in the whole world without leaving my room.
0:01:32 Object 0:03:33 0:05:00 0:06:00 0:08:00 0:09:05 Creating and using your own type with classes 0:11:28 Define your own type 0:13:01 What are attributes 0:14:44 Defining how to create an instance of a classes 0:16:00 0:18:49 Actually creating an instance of a classes 0:20:38 0:22:00 Define a method for the coordinate class 0:24:29 How to use a method 0:26:00 0:27:40 0:30:52 0:32:36 Special operators 0:33:59 Class "Fraction" 0:36:00 0:38:08 Class "Fraction" used to compute 0:39:44
This explained Python objects so much better than any online tutorial I've read. Will definitely watch more of these lectures.
1. Objects comprise of 2 parts,data members and methods. 2. In effect,methods are a special type of function,function that is exclusive to an object. 3. By default,it would be meaningless to print an object,but we can reimplement our method by defining _str_ function.Likewise,we can implement addition,subtraction of objects and so on. 4. OOP is actually quite prevalent in computer science because it shields the details of a complex object from the user. It is a form of abstraction which simplifies the implementation of an application.
I never thought of a class as a way to implement your own datatype. And the way she introduced that, after explaining how existing things were primitive type objects that had methods encapsulated inside them, was brilliant.
00:02 Object-oriented programming is about everything in Python being an object. 02:38 Objects are data abstractions with representation and interface 07:07 Object-oriented programming allows bundling data and interactions into packages for reusable and readable code. 09:20 Defining and using custom classes in Python 13:58 Creating and interacting with coordinate points in object-oriented programming 16:28 Methods and parameters in initializing a class 21:06 Adding methods to interact with objects 23:14 Using dot notation to access data attributes in classes 27:20 Defining a custom method for printing objects of a specific type in Python 29:25 Defining the Str method for the coordinate object. 33:58 Object Oriented Programming: Fraction object representation 36:19 Implementing fraction object using object-oriented programming 41:01 Object-oriented programming allows bundling similar objects with common properties and methods.
As my token of gratitude Id like to give Ana another black shirt as a present to add to her already extensive collection of black shirts.
At 20 minutes in I was blown away at how fast it suddenly clicked for me. Wow! Great job, Dr. Bell!
I know this is a three year old video, but this is really well produced and presented. This professor represents the MIT brand well. Meticulous in detail but yet, easy to understand. Excellent lecture. The best presentation I have seen on the subject, and I've seen a few. Thank you.
Thank you very much MIT, Dr Ana Bell and all of contributors and donors
Such a Privilege and Honor to hear Dr. Bell's lecture on Python thank you MIT Open Course Ware.
I heard once to think of OOP classes as blueprints. It made so much more sense to me that way.
Till date , tis is the best way of teaching the class and objects concepts, typical employee class example has done nothing but creating confusion n hence failure in implementing classes when needed to many people.. Ana tis S epic tutorial.. Thanks MIT
Thank you so very much dr bell! After months of searches and reading books, I’m really happy to have finally understood oop in python ! You are amazing ! Thank you so very much ! And thank you MIT !
Hi. I am a beginner in python and find this course very helpful. I think the best part (and hence probably the most challenging) is that all the needed information is well packed into a few lectures. Thanks!
What a joy it must be to teach at MIT. You get listened to, and you get asked interesting questions. Excellent teaching this is.
Thank you Dr. Ana Bell and MIT! The diagram and explanation at 19:30 is when I finally understood why self is needed. (I think)
A bundle of thanks to MIT and especially to instructor : DR. ANA BELL..|||
guys, tips for you beginners / intermiadtes: function is the same as method except that methods are called methods cos they are in class, but it's the same as function, function is OUTSIDE class and methods are INSIDE class. But aside that it's the same thing. Another tip is that self. You use self ALWAYS (as long it's not static method) in class methods as a first parameter, even if method do not return anything, IT MUST HAVE that 1st parameter called self (stick to self). Another example, lady showed you bad example in 25:50, there is an easy way to do it by just declaring "static method" inside class so then you could use 2 objects like c.x and zero.x. And also I'd like to add this important answet to student who asked "how do we know if it's a float/string or int", we could determine specific data type in that constructor _init_ (or call it whatever you want) by just adding simple notation like def _init_ (self, x: str, y: int): ... so now if you have mypy, it will always watch if X is string and Y int, if not then error. You dont need to add some extra code inside method as lady said, waste of lines. and Lastly important info for you, join official python discord for help/resources here: https://discord.gg/python and here you have some resources you can learn from / improve: https://pythondiscord.com/pages/resources/
@leixun