🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Type Hints and Dataclasses: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What happens when you call def f(n: int) as f("hi")?
  2. Q2. What does - float mean in def area(r: float) - float:?
  3. Q3. Which hint means "an int or None" in Python 3.10+?
  4. Q4. Which methods does a plain @dataclass generate?
  5. Q5. What does this print? (code)
  6. Q6. How do you give each dataclass object its own new empty list?
  7. Q7. What does this print? (code)
  8. Q8. What does frozen=True do to a dataclass?
  9. Q9. When does postinit run?
  10. Q10. What does this print? (code)