Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan

Walk Through a Python Script

MediumCoding00:00
Practice interviewer
In session
5 left
00:00

Your question is Walk Through a Python Script. Take a moment with it on the right.

Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).

You need to log in / sign up to chat or submit.

Problem

Turck builds industrial sensors, and its QA team runs an automated pass or fail check against every sensor reading before a batch ships. You're handed this Python script during a QA engineering interview and asked to walk through it end to end.

import time

def run_sensor_checks(readings, thresholds, retries=[]):
    results = []

    for sensor_id, value in readings.items():
        threshold = thresholds.get(sensor_id, thresholds["default"])
        attempt = 0
        passed = False

        while attempt < 3:
            if value <= threshold:
                passed = True
                break
            attempt += 1
            time.sleep(0.1)
            retries.append(sensor_id)

        results.append({
            "sensor_id": sensor_id,
            "value": value,
            "threshold": threshold,
            "passed": passed,
            "attempts": attempt + 1
        })

    return results


def summarize(results):
    total = len(results)
    failed = [r for r in results if not r["passed"]]
    pass_rate = (total - len(failed)) / total * 100

    return {
        "total": total,
        "failed": len(failed),
        "pass_rate": round(pass_rate, 1)
    }

Explain what run_sensor_checks and summarize do, in the order they execute. As you walk through it, call out anything you would flag in a code review, including behavior that only shows up on repeated calls or on edge-case inputs, since that's exactly what a QA engineer is expected to catch before this ships.