Annotated variables (x: int = 0)
You can write the expected type of a variable after a colon, before the equals sign: `x: int = 0`.
Used in 50 lessons of the course, from 00.01.
An annotated assignment has three parts: the name, a : with the type hint, and optionally = value.
count: int = 0 assigns 0 to count and tells whoever reads the code (and editors) that count should be an int.
Python does not check the hint at runtime. If you write count: int = "hola", it runs without error. The hint is information for people and tools.
You can annotate without assigning: name: str. That does not create the variable; it only declares the type.
You see it in the course from lesson 00.01: GLOSSARY: dict[str, tuple[str, str]] = {. Read it as: GLOSSARY is a dict with string keys and values that are tuples of two strings. The right side is a normal dict.
It is also the basis of fields in classes like Pydantic's: name: str = "x".
Reach for it when: you want to make clear what type a variable holds, especially a collection or one that starts empty.
Examples
Common mistake
name: str print(name)
Why: Annotating without `=` only declares the type; the name does not exist yet.
How to write it: Assign a value: name: str = "Ada".
