Python Roadmap for Beginners + Cheat Sheet
1. Introduction to Python
- What is Python?
- Installing Python (via python.org or Anaconda)
- Running Python scripts: IDLE, VS Code, Jupyter, Terminal
2. Basic Syntax
- print(), comments (#)
- Variables and Data Types: int, float, str, bool
- Type conversion: str(), int(), float()
3. Operators
- Arithmetic: + - * / // % **
- Comparison: == != > < >= <=
- Logical: and, or, not
- Assignment: = += -=
4. Conditional Statements
if condition:
# code
elif another_condition:
# code
else:
# code
5. Loops
# while loop
while condition:
# code
# for loop
for i in range(5):
# code
6. Data Structures
- List: [], methods: .append(), .remove()
- Tuple: (), immutable
- Set: {}, unique values
- Dictionary: {"key": "value"}
7. Functions
def function_name(params):
return result
8. Modules and Packages
- import math
- from datetime import datetime
9. File Handling
with open("file.txt", "r") as file:
content = file.read()
10. Exception Handling
try:
# code
except Exception as e:
print(e)
11. Object-Oriented Programming (OOP)
class Person:
def __init__(self, name):
self.name = name
Python Cheat Sheet (Quick Reference)
| Concept | Example |
|---------------|----------------------------------|
| Print | print("Hello, World") |
| Variable |x=5 |
| List | mylist = [1, 2, 3] |
| If-else | if x > 5: |
| For loop | for i in range(5): |
| Function | def add(a, b): return a + b |
| Dictionary | {"name": "Ana"} |
| Input | input("Enter: ") |
| String format | f"Name: {name}" |
| Import | import math |