Use Equality Operator to Compare the Value of Objects in Python

Mridu Bhatnagar
InstructorMridu Bhatnagar
Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 3 years ago

While solving real-life use cases through programming and also while testing your code you will come across scenarios where you have to compare the value of different objects. And, then to solve the problem you can use the equality operator.

Mridu Bhatnagar: [0:02] Compare the objects having equal values using the equality operator. Variable a is assigned to an integer object having value 40. Let us assign variable b to integer object having value 40. Now, we need to compare both the objects. For comparing we'll do a == b.

[0:32] Double equal to is our equality operator. The result that you see is True. The result is true because value of both the objects are same.

[0:50] Now, let us compare the objects having unequal values. Let us assign a variable c to an integer object having value 50. Let us assign a variable d to an integer object having value 60. Then, we can do c == d.

[1:20] Double equal to is our equality operator. When you do Enter, the result now is False. This is so, because both the values of objects were different.

egghead
egghead
~ 28 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today