← 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 →- Q1. What happens when you call def f(n: int) as f("hi")?
- Q2. What does - float mean in def area(r: float) - float:?
- Q3. Which hint means "an int or None" in Python 3.10+?
- Q4. Which methods does a plain @dataclass generate?
- Q5. What does this print? (code)
- Q6. How do you give each dataclass object its own new empty list?
- Q7. What does this print? (code)
- Q8. What does frozen=True do to a dataclass?
- Q9. When does postinit run?
- Q10. What does this print? (code)