Python Basics Summary
1. Variables & Data Types:
- int, float, str, bool, list, tuple, dict, set
2. Operators:
- Arithmetic: +, -, *, /, %, **, //
- Comparison: ==, !=, >, <, >=, <=
- Logical: and, or, not
3. Control Flow:
- if, elif, else
- for loops, while loops
- break, continue
4. Functions:
- def my_function(param):
- return value
5. Collections:
- List: ordered, mutable
- Tuple: ordered, immutable
- Set: unordered, unique values
- Dict: key-value pairs
6. Strings:
- "Hello".lower(), "Hello".upper(), "Hello".split(), " ".join(list)
7. Input & Output:
- input("Enter: ")
- print("Hello")
8. Modules:
- import math
- from random import randint
9. File Handling:
- f = open("file.txt", "r")
- f.read(), f.write()
- f.close()
10. Exceptions:
- try:
# code
except Exception as e:
# handle error
---
Quick Reference for Beginners.