← All mindmapsMAIN TOPIC · 01 / 14

Python Programming

Core language, data structures, OOP and runtime

Explore full topic ↗
100%
Python Programming overview revision sheet; full text available below

Use + to enlarge the vector sheet up to 400%, then pan horizontally or vertically. A readable text version is below.

Readable revision notes (18 concepts)

The same content as the visual sheet, optimized for mobile and assistive technology.

01 · Data types

  • int, float, bool, str, None; strings immutable
  • List: ordered mutable; tuple: immutable sequence
  • Set: unique hashable items; dict: key → value

02 · Collections & complexity

  • List index O(1); membership O(n)
  • Dict/set lookup average O(1); worst O(n)
  • deque: efficient append/pop at both ends

03 · Functions

  • *args collects positional; **kwargs keyword args
  • LEGB scope; closures retain enclosing names
  • Avoid mutable defaults; use None sentinel

04 · Iteration & comprehensions

  • iter(x) → next(); StopIteration ends iteration
  • yield suspends generator; lazy, one-pass
  • [f(x) for x in xs if p(x)]

05 · Object-oriented Python

  • Class defines behavior; instance holds state
  • self, __init__, inheritance, polymorphism
  • MRO resolves methods; dataclass reduces boilerplate

06 · Copying & identity

  • == compares values; is compares identity
  • Shallow copy shares nested objects
  • deepcopy recursively copies supported objects

07 · Exceptions & resources

  • try / except / else / finally
  • with manages acquire/release via context manager
  • raise preserves or chains failure context

08 · Concurrency & runtime

  • asyncio: cooperative I/O concurrency
  • Threads for I/O; processes often for CPU work
  • GIL applies to standard CPython builds; optional free-threading

09 · Interview checklist

  • Decorators wrap callables; @property exposes accessor
  • Type hints document contracts; not runtime checks
  • Test edge cases; use venv, logging, unit tests

10 · Memory & mutability

  • Assignment binds a name, not copies an object.
  • Mutable list/dict/set can change through aliases; tuple immutability is shallow.
  • CPython reference counting plus cyclic GC; del removes binding, not necessarily object.

11 · Sequence & mapping operations

  • Slice a[start:stop:step]; slice creates new list, not deep copy.
  • Dict keys must be hashable; insertion order preserved; sets unordered.
  • list.sort mutates and returns None; sorted creates new list.

12 · Function signatures

  • Positional-only / and keyword-only * enforce calling contract.
  • Defaults evaluated once at definition; use None for mutable defaults.
  • Functions are objects; closures capture bindings, late binding in loops.

13 · Decorators & generators

  • Decorator receives callable and returns replacement; functools.wraps preserves metadata.
  • Generator yield pauses execution; yield from delegates iteration.
  • Generator expressions save memory; exhausted iterator must be recreated.

14 · OOP & dunder methods

  • __init__ initializes after __new__; __repr__ debugging; __str__ user display.
  • class method receives cls; static method no implicit self; property manages access.
  • Composition often preferable to deep inheritance; super follows MRO.

15 · Concurrency & async

  • await yields control only on cooperative suspension; blocking calls stall loop.
  • Threads share memory; processes isolate memory; use locks/queues when needed.
  • GIL limits parallel Python bytecode in conventional CPython; native code may release it.

16 · NumPy essentials

  • ndarray shape/dtype/axes; vectorized operations avoid Python loops.
  • Broadcast compares trailing dimensions: equal or one; incompatible shapes fail.
  • Basic slices are often views; advanced indexing copies. Check shares_memory.

17 · Pandas essentials

  • loc label-based; iloc position-based; use explicit assignment.
  • groupby aggregation; merge joins; check duplicate keys and missing values.
  • Use vectorized operations; parse dates and validate dtypes.

18 · Testing & packaging

  • Use virtual env and pinned dependency lock; modules/packages organize code.
  • pytest assertions/fixtures; mock external IO; test error paths.
  • Logging levels, traceback, profiling; never hardcode secrets.

References & further study

Original schematics illustrate concepts, not measured data. Review these references for full derivations and implementation details.

Last 30 min revisionHigh-yield interview Q&As