Last reviewed
Correct answer: B. You don't need to explicitly declare a variable's type; it's determined at runtime
Explanation
Dynamically typed means the name carries no type; the object does. "Names refer to objects. Names are introduced by name binding operations," and "Every object has an identity, a type and a value." So writing count = 5 does not declare count to be an integer. It binds the name count to an integer object, and rebinding count to a string on the next line is perfectly legal, because you are only changing what the name points at.
The mistake worth avoiding is hearing "dynamically typed" as "untyped." Python checks types strictly. It just checks them at runtime, at the moment of the operation, so adding a string to an integer raises TypeError when that line actually executes rather than when you save the file. A type bug can therefore sit undisturbed inside a branch nobody exercises until production traffic finds it. Annotations do not change that: "The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc." Tests and a checker earn their keep here.
Sources
“Names refer to objects. Names are introduced by name binding operations.”
“Every object has an identity, a type and a value.”
“The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc.”
Practise 3 questions on this topic
Take Python Basics — Timed Test (3 questions) — scored instantly, explanation for every question, no login.