Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

Which method is used to compare objects for equality?

View

What will a == b return if __eq__() is not implemented?

View

Which magic method is used for the != operator?

View

What does the is operator compare?

View

What is the output of the following code?

View

What is the output of this code?

View

Which operator checks if two objects are not the same in memory?

View

Which of the following returns True for a == b?

View

How do you customize the behavior of < operator?

View

Which method is called when a > b is evaluated?

View

Which method is used to compare objects for equality?

__cmp__()
__eq__()
__compare__()
__equals__()

What will a == b return if __eq__() is not implemented?

True
False
Compares memory addresses
Raises an error

Which magic method is used for the != operator?

__eq__()
__ne__()
__neq__()
__cmp__()

What does the is operator compare?

Value of objects
Memory addresses of objects
Type of objects
Length of objects

What is the output of the following code?

a = [1, 2, 3] b = a print(a is b)

True
False
None
Error

What is the output of this code?

a = [1, 2, 3] b = [1, 2, 3] print(a == b, a is b)

True True
True False
False True
False False

Which operator checks if two objects are not the same in memory?

!=
is not
==
not in

Which of the following returns True for a == b?

If a and b are different objects with the same values
If a and b are the same objects
If a and b are different classes
If a or b is None

How do you customize the behavior of < operator?

By defining __compare__()
Using __lt__() method
By overriding __ne__()
Through the @classmethod decorator

Which method is called when a > b is evaluated?

__lt__()
__gt__()
__compare__()
__ge__()