🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Type Hints and Dataclasses: all 10 questions

Quiz: Type Hints and Dataclasses · Question 1 of 10

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

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

  1. A.Python raises a TypeError immediately
  2. B.Python runs it; hints are not checked at runtime
  3. C.Python converts "hi" to an int
  4. D.The call is skipped
Answer & explanation

Correct answer: Python runs it; hints are not checked at runtime

Hints are stored, not enforced. A type checker like mypy would report the problem before running.

Can you get the rest right without peeking?

Take the timed Quiz: Type Hints and Dataclasses quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →