Skills101
← All practice quizzes

Quiz: Type Hints and Dataclasses

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

Type hints document what a function expects and returns, and let tools catch mistakes before you run the code. Dataclasses write init, repr and eq for you. Learn both with practical examples.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What happens when you call def f(n: int) as f("hi")?

  2. Question 2

    What does -> float mean in def area(r: float) -> float:?

  3. Question 3

    Which hint means "an int or None" in Python 3.10+?

  4. Question 4

    Which methods does a plain @dataclass generate?

  5. Question 5

    What does this print?

    from dataclasses import dataclass
    @dataclass
    class P:
        x: int
        y: int = 0
    print(P(3))
    
🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →