Python Reference Guide
This Python Reference is a quick and structured guide for developers, students, and interview candidates.
It helps you quickly recall important concepts of Python without going through long tutorials.
🟢 1. Basic Syntax
print("Hello, Python")
- Python uses indentation instead of braces
- Case-sensitive language
- No semicolons required
🟢 2. Variables
x = 10
name = "Alice"
- Dynamically typed
- No declaration needed
🟢 3. Data Types
- int → 10
- float → 10.5
- str → "text"
- bool → True/False
- list → [1, 2, 3]
- tuple → (1, 2, 3)
- dict → {"key": "value"}
- set → {1, 2, 3}
🟢 4. Operators
Arithmetic
+ - * / // %
Comparison
== != > < >= <=
Logical
and, or, not
🟢 5. Conditional Statements
if x > 10:
print("Greater")
elif x == 10:
print("Equal")
else:
print("Smaller")
🟢 6. Loops
For Loop
for i in range(5):
print(i)
While Loop
i = 0
while i < 5:
i += 1
🟢 7. Functions
def add(a, b):
return a + b
-
Defined using
def - Can return values
🟢 8. Lists
nums = [1, 2, 3]
nums.append(4)
Common Methods:
- append()
- insert()
- remove()
- pop()
- sort()
🟢 9. Tuples
t = (1, 2, 3)
- Immutable
- Faster than lists
🟢 10. Dictionaries
data = {"name": "John", "age": 25}
Methods:
- keys()
- values()
- items()
🟢 11. Sets
s = {1, 2, 3}
- No duplicates
- Unordered
🟡 12. Object-Oriented Programming (OOP)
class Person:
def __init__(self, name):
self.name = name
Concepts:
- Class
- Object
- Inheritance
- Polymorphism
- Encapsulation
🟡 13. Exception Handling
try:
x = 10 / 0
except ZeroDivisionError:
print("Error occurred")
finally:
print("Done")
🔵 14. File Handling
with open("file.txt", "r") as f:
data = f.read()
Modes:
- r → read
- w → write
- a → append
🔵 15. Modules & Imports
import math
print(math.sqrt(16))
🔵 16. Advanced Concepts
- Decorators
- Generators
- Context Managers
- Coroutines (async/await)
- Data Model (magic methods)
All are advanced features of Python.
🧠 17. Built-in Functions
- print()
- len()
- type()
- input()
- range()
- sum()
- max()
- min()
⚡ 18. Quick Tips
- Use meaningful variable names
- Follow PEP 8 style guide
- Prefer list comprehensions
- Use virtual environments for projects
📊 Summary
This Python Reference Guide provides a quick lookup of essential programming concepts including syntax, data structures, OOP, and advanced topics in Python.
🚀 Conclusion
This reference is designed for fast revision and daily use by developers working with Python.
Keep it as a cheat sheet for interviews, projects, and coding practice.


0 Comments