INTERVIEW PREP
Interview questions
570 questions from real DevOps, SRE, platform engineering and MLOps interviews, with the answer an interviewer wants to hear. Try answering out loud first, then open the model answer.
Showing 61–75 of 570 questions
61.Why use a virtual environment?BeginnerPython for DevOps
It gives each project its own Python packages, so versions never clash between projects and your system Python stays clean.
62.What is the difference between a list and a dict?BeginnerPython for DevOps
A list is an ordered group of items you reach by position. A dict stores values under names (keys), so you reach them by key.
63.How do you read a file safely?BeginnerPython for DevOps
Use a with block: with open(path) as f. It closes the file even when an error happens. pathlib makes paths work on every system.
64.What does exit code 0 mean?BeginnerPython for DevOps
Success. Any other number means failure. CI systems and shells read this number, so scripts should exit non-zero when they fail.
65.Why is shell=True dangerous in subprocess?MidPython for DevOps
The text is parsed by a shell, so special characters from outside input can run extra commands. Pass the command as a list of arguments instead.
66.How do you call a REST API safely from Python?MidPython for DevOps
Use requests with a timeout, call raise_for_status(), keep tokens in environment variables, handle paging, and retry on 429 and 5xx.
67.What is yaml.safe_load and why prefer it?MidPython for DevOps
It parses YAML into plain data only. The unsafe loader can create arbitrary Python objects, so a crafted file could run code.
68.What does idempotent mean for an automation script?MidPython for DevOps
Running it again gives the same end result and causes no harm. Check what exists first, then create, update or skip.
69.Why use logging instead of print?MidPython for DevOps
Logging gives timestamps and levels, can write to files, and can be turned up or down without changing code.
70.What is exponential backoff?MidPython for DevOps
Waiting longer after each failed try, such as 1s, 2s, 4s. It gives a busy service time to recover. Always cap the number of tries.
71.How do you test code that calls AWS?MidPython for DevOps
Mock the client in unit tests or use moto to fake AWS. Keep real-cloud tests few, slow and separate.
72.What is a paginator in boto3?SeniorPython for DevOps
A helper that follows the page tokens of an AWS API for you, so you get every result rather than only the first page.
73.How should a Python script get AWS credentials in production?SeniorPython for DevOps
From an IAM role attached to the compute (EC2, ECS, Lambda or an EKS service account). No long-lived keys in code or files.
74.load_kube_config or load_incluster_config?SeniorPython for DevOps
load_kube_config reads your local kubeconfig and suits laptops. load_incluster_config uses the pod's service account and suits code running in the cluster.
75.Threads, asyncio or processes?SeniorPython for DevOps
Threads for a moderate number of I/O waits, asyncio for very many connections with async libraries, processes for CPU-heavy work. Always limit concurrency.