>DevOps Interview KB

Python Interview Questions

10 questions

Python interview questions focused on the automation and tooling use cases DevOps roles actually need Python for, not general-purpose language trivia.

Related technologies:DockerPython

A Python CLI tool used in CI pipelines always exits with code 0, even when it detects and reports a real failure. What breaks because of this, and how do you fix it?

IntermediatePython6 min

An automation script opens a database connection, does some work, and closes it at the end — but an exception partway through leaves the connection open. Why does 'with' fix this, and how does it actually work?

IntermediatePython6 min

You want to speed up a Python automation script that processes many files. Should you use threading or multiprocessing? What does the GIL actually have to do with this decision?

IntermediatePython7 min

A script calling a flaky API retries immediately with a fixed 1-second delay. During a real outage, this made things worse. Why, and how should retry logic actually be designed?

IntermediatePython7 min

A log-processing script uses json.load() to parse a multi-gigabyte newline-delimited JSON log file and gets killed with an out-of-memory error. What's wrong, and how do you fix it?

IntermediatePython7 min

A Python automation script uses subprocess.run(f'kubectl get pod {pod_name}', shell=True) where pod_name comes from user input. What's actually wrong with this, and how do you fix it?

AdvancedPython7 min

What's the difference between a Docker container being OOM-killed by its own cgroup memory limit versus the host machine itself running out of memory?

IntermediateDocker6 min

Why does Docker report exit code 137 specifically for an OOM-killed container, and how does that map to the underlying kernel signal?

BeginnerDocker5 min

How would you handle a data transformation that genuinely needs to see the whole dataset at once, like a global sort, when streaming isn't an option?

AdvancedPython8 min

A Python script that processes a large file works fine on your laptop but gets OOM-killed when run in a container with a memory limit. What's likely wrong, and how do you fix it?

IntermediatePythonDocker8 min