Nội dung chính của trang này bằng tiếng Anh.Dịch trang này
Kỹ năng & công nghệ
Python roadmap
Learn Python from zero to writing clean, tested, professional code. Python is the main language for AI, data science, automation and many backends.
- Thời gian
- ⏱ 6–8 weeks
- Level
- Beginner
- Steps
- 6 steps
- Progress
- 0/6 done
The roadmap
Click a step to open the full guide.
Python cheat sheet
The essentials on one screen. Bookmark it for revision.
Syntax
| f-string | f"Total: {total:.2f}" |
|---|---|
| List comprehension | [x for x in xs if x] |
| Dict comprehension | {k: v for k, v in pairs} |
| Unpacking | a, b = b, a |
| Safe dict get | d.get("key", default) |
| Enumerate | cho năm i, x in enumerate(xs): |
| Zip | cho năm a, b in zip(xs, ys): |
| Lambda sort | sorted(xs, key=lambda x: x["price"]) |
Commands
| New venv | python -m venv .venv |
|---|---|
| Activate (Windows) | .venv\Scripts\activate |
| Activate (Mac/Linux) | source .venv/bin/activate |
| Install | pip install httpx |
| Run tests | pytest -q |
| Lint + format | ruff check . && ruff format . |
Improve performance
- Use the right data structure: dicts/sets for lookups instead of searching lists.
- Use built-ins (
sum,sorted,max) and comprehensions; they run in fast C code. - Use
asyncor threads for many network calls; multiprocessing for CPU-heavy work. - Profile before optimising:
python -m cProfile script.pyshows where time goes. - Use generators for large data so you don't load everything into memory.
- Cache repeated expensive calls with
functools.lru_cache.
Security checklist
- Never hard-code secrets; use environment variables.
- Never use
eval()/exec()on user input. - Use parameterised SQL queries, never string formatting.
- Pin and audit dependencies (
pip-audit); install only trusted packages. - Validate all external input (Pydantic) and set timeouts on network calls.
Most important interview questions
Click a question to see a strong answer. Each step also has its own questions.
1What are Python's main data types?
int, float, bool, str, list, tuple, dict, set and None; plus bytes for binary data.
2a generator là gì?
A function that uses yield to produce values one at a time, saving memory for large or infinite sequences.
3Explain list vs dict lookup performance.
Checking x in list scans every item (O(n)); x in dict/set uses hashing (O(1) on average).
4the difference between deep and shallow copy là gì?
A shallow copy copies the outer container but shares nested objects; a deep copy (copy.deepcopy) copies everything recursively.
5How does Python manage memory?
Reference counting plus a cyclic garbage collector; objects are freed when no references remain.
6What are decorators used for in real projects?
Adding cross-cutting behaviour such as routes in web frameworks, caching, retries, logging, timing and access checks.
Related lộ trình
Python Developer
6 steps · 4–5 months · Beginner
Build backends, automation and data tools with Python.
View roadmap →FastAPI
6 steps · 3–4 weeks · Intermediate
Build fast, documented Python APIs.
View roadmap →AI Engineer
6 steps · 4–6 months · Intermediate
Build products on top of large language models.
View roadmap →Data Analyst
6 steps · 3–4 months · Beginner
Turn data into answers and dashboards.
View roadmap →