🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

कौन सा ऑपरेटर _gt_() overload किया जाता है?

Which operator is overloaded by the method _gt_() ?

A
< (less than)
B
> (greater than)
C
!= (not equal)
D
None
Explanation

Python में special methods (जिसे dunder methods भी कहते हैं, जैसे __gt__()), operators को overload करने के लिए इस्तेमाल होते हैं।

  • __gt__() का मतलब है:
    "greater than" (>) operator को overload करना"


🔸 Example:

class MyNumber:
    def __init__(self, value):
        self.value = value

    def __gt__(self, other):
        return self.value > other.value

a = MyNumber(10)
b = MyNumber(5)

print(a > b)   # True → because __gt__() is called

 

Correct Answer: B) > (greater than)

Latest Updates