1. Core Syntax
Indentation defines blocks. Dynamic typing.
x = 10 # int
name = "BH" # str
nums = [1,2,3] # listControl: if/elif/else, for, while, break/continue
Functions: def, *args, **kwargs, lambda
2. Data Structures
- list — mutable, ordered
- tuple — immutable
- dict — key→value, O(1) avg
- set — unique, unordered
Comprehensions
[x*x for x in range(10) if x%2==0]
Slicing: a[start:stop:step]
3. OOP & Libraries
class Student:
def __init__(self, name):
self.name = nameLibraries
- NumPy — arrays & math
- Pandas — dataframes
- Matplotlib — plotting
- requests — HTTP
File I/O: with open("f.txt") as f: ...
Exceptions: try/except/finally