You can use this assignment in your class!
Mastery Progress(100.0%)
i

Object-Oriented Programming (OOP) in Python Assignment

You answeredJUST NOW
Python
You passed all test cases!
STDIN
Jason, Jason
Expected STDOUT
Objects are equal
Your STDOUT
Objects are equal
STDIN
Sarah, Jennifer
Expected STDOUT
Objects are NOT equal
Your STDOUT
Objects are NOT equal

Did you like this question?

(Voting helps us personalize your learning experience!)
imgInstructor solution
Alec KretchJAN 2, 2021, 10:14:55 PM
Python

Was this helpful?

(Voting helps us personalize your learning experience!)
imgObject-Oriented Programming (OOP) in Python presentation (pages 3, 4)

Was this helpful?

(Voting helps us personalize your learning experience!)
Think you've got it?
  • Code as follows:

class DunderObj:
    def __init__(self, name):
        self.name = name
        
    def __eq__(self, other):
        return self.name == other

objA = DunderObj("Jason")
objB = "Jason"
if objA == objB:
    print("Objects are equal")
else:
    print("Objects are NOT equal")Figure A
Select one of the following options:
  • A.
  • B.
  • C.
  • D.
Submit answer

Was this helpful?

(Voting helps us personalize your learning experience!)

You may exit out of this review and return later without penalty.