Python Programming Cheat Sheet
PYTHON PROGRAMMING CHEAT SHEET
1. Basics:
- Variables: x = 5
- Data Types: int, float, str, bool, list, dict
- Input/Output: input(), print()
2. Control Structures:
- if, elif, else
- for and while loops
- break, continue, pass
3. Functions:
- def func_name(params):
- return keyword
- Lambda functions
4. Data Structures:
- Lists: append(), remove(), slicing
- Tuples, Sets, Dictionaries
- List comprehensions
5. Modules and Libraries:
- import math, random, datetime
- pip install package_name
6. File Handling:
- open(), read(), write(), close()
- with open("file.txt", "r") as f
7. Error Handling:
Python Programming Cheat Sheet
- try-except-finally blocks
8. OOP Concepts:
- class, object, __init__(), self
- inheritance, polymorphism