← 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")?
- A.Python raises a TypeError immediately
- B.Python runs it; hints are not checked at runtime
- C.Python converts "hi" to an int
- 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 →