← All topics
Quiz: Magic Methods and Properties: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. Which method does len(obj) call?
- Q2. What does this print? (code)
- Q3. If a class defines only repr, what does print(obj) use?
- Q4. Without eq, what does a == b check for two objects of your class?
- Q5. What does this print? (code)
- Q6. Which decorator writes <=, and = for you from eq and lt?
- Q7. What does this print? (code)
- Q8. What is the first parameter of a @classmethod?
- Q9. When is @staticmethod the right choice?
- Q10. Why might objects of a class that defines eq fail to go into a set?