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 function_name(params):
return value
5. Collections:
- list: ordered, mutable
- tuple: ordered, immutable
- dict: key-value pairs
- set: unordered, unique items
6. String Basics:
- Indexing: text[0], text[-1]
- Methods: lower(), upper(), strip(), split(), join()
7. Input/Output:
- input("Enter: ")
- print("Hello")
8. Modules:
- import module_name
- from module import function
9. File Handling:
- open("file.txt", "r")
- read(), readline(), write(), close()
10. Exceptions:
- try:
# code
except Exception as e:
# handle error