Object equality | Intro to CS - Python | Khan Academy

  Open with LBRY

How does the computer decide whether two objects are equal? By default, Python compares objects based on identity, but we can override that behavior by implementing the __eq__() method.

View the program used in this video at:
https://www.khanacademy.org/python-program/object-equality/6560227012493312

Courses on Khan Academy are always 100% free. Start practicing—and saving your progress—now with our Intro to Computer Science - Python course!

Course link: https://www.khanacademy.org/computing/intro-to-python-fundamentals/x5279a44ae0ab15d6:building-software-with-classes
Course playlist: https://www.youtube.com/playlist?list=PLSQl0a2vh4HDkbhG0sDW0b-VZXykEIAe5

Khan Academy is a nonprofit organization with the mission of providing a free, world-class education for anyone, anywhere. We offer quizzes, questions, instructional videos, and articles on a range of academic subjects, including math, biology, chemistry, physics, history, economics, finance, grammar, preschool learning, and more. We provide teachers with tools and data so they can help their students develop the skills, habits, and mindsets for success in school and beyond. Khan Academy has been translated into dozens of languages, and 15 million people around the globe learn on Khan Academy every month. As a 501(c)(3) nonprofit organization, we would love your help!

Donate or volunteer today! Donate here: https://www.khanacademy.org/donate?utm_source=youtube&utm_medium=desc

Volunteer here: https://www.khanacademy.org/contribute?utm_source=youtube&utm_medium=desc

TIMESTAMPS:
00:00 : identity comparison
00:31 : Card class
00:57 : comparing Cards
01:36 : __eq__() method
02:13 : __eq__() syntax
03:11 : when does __eq__() execute?
03:53 : comparing rank attributes
04:32 : comparing ranks and suits
...
https://www.youtube.com/watch?v=h1buswZOrmI
Note: All Khan Academy content is available for free at (www.khanacademy.org)