Interview knowledge

Coding topics to refresh before an interview

Growingest.Started 13 Sept 20261 min read#interviewing#python#engineering

Coding topics to refresh

Python

Be comfortable with:

  • dictionaries / sets / lists
  • comprehensions
  • iterators/generators
  • collections
  • sorting
  • exceptions
  • context managers
  • dataclasses
  • typing
  • JSON
  • HTTP
  • files
  • async basics

Counting

from collections import Counter

counts = Counter(items)

Enumerate

for index, item in enumerate(items):
    ...

Zip

for name, score in zip(names, scores):
    ...

Sort

users.sort(key=lambda user: user.created_at)

or

users = sorted(users, key=lambda user: user.name)

descending:

sorted(users, key=lambda user: user.score, reverse=True)

any, all, min, max, sum

if any(user.active for user in users):
    ...

if all(user.valid for user in records):
    ...

highest = max(records, key=lambda r: r.score)

Iterators and generators

Remember the distinction:

values = [expensive(x) for x in items]

creates the entire list.

Whereas:

values = (expensive(x) for x in items)

is lazy.

For a large dataset:

for item in read_records():
    process(item)

can be much better than loading everything into memory.

Also remember:

yield

for generator functions.

This could easily come up if they give you data-processing work.

async

You may see:

async def fetch():
    result = await client.get(...)
    return result

Remember:

  • async def creates a coroutine
  • await yields control while waiting
  • async is useful for I/O-heavy concurrency

Don't use async just because it's available.

A useful interview line:

“This workload is I/O-bound, so async could help if we're making many independent external calls.”

And if you have several independent calls:

results = await asyncio.gather(
    fetch_a(),
    fetch_b(),
    fetch_c(),
)

Know what that means, but don't worry about advanced asyncio.

Testing

Know how to:

  • isolate units
  • mock external services
  • test API endpoints
  • test failure cases
  • write fixtures
    Practical engineering
    Refresh:
  • logging
  • configuration
  • environment variables
  • dependency injection
  • database access
  • transactions
  • HTTP retries