Python Syntax and Data Types
A beginner-friendly tour of Python syntax, variables, strings, lists, dictionaries, and type hints with examples.
Python's readability is its superpower. Let's cover the building blocks.
Variables and dynamic typing
name = "Ada"
age = 36
scores = [95, 87, 91]Python is dynamically typed, but you can add type hints for better tooling:
age: int = 36.
Common data types
| Type | Example | Notes |
|---|---|---|
str | "hello" | Immutable sequence of chars |
list | [1, 2, 3] | Ordered, mutable |
dict | {"a": 1} | Key-value mapping |
tuple | (1, 2) | Ordered, immutable |
set | {1, 2, 3} | Unordered, unique items |
A quick loop
for score in scores:
print(f"Score: {score}")Quick Summary
- Python uses dynamic typing; add type hints for better tooling.
- Five core types:
str,list,dict,tuple,set. - f-strings are the cleanest way to format output.
AdSense — in-article slot