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

Write a Simple Function Test

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

Your question is Write a Simple Function Test. 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

You're interviewing for a QA Engineer role at ScienceLogic, which monitors IT infrastructure and alerts on devices with abnormal uptime. Here's a function used to parse a device's reported uptime string into seconds, which then feeds an alert that fires when a device's uptime looks suspiciously low right after it should have been rebooted.

def parse_uptime_to_seconds(uptime_str):
    # uptime_str examples: "5d 3h 12m", "0d 0h 45m", "2h", "90m"
    if not uptime_str:
        return 0

    total_seconds = 0
    parts = uptime_str.strip().split(" ")

    for part in parts:
        if part.endswith("d"):
            total_seconds += int(part[:-1]) * 86400
        elif part.endswith("h"):
            total_seconds += int(part[:-1]) * 3600
        elif part.endswith("m"):
            total_seconds += int(part[:-1]) * 60

    return total_seconds

Describe, as a set of concrete test cases, how you'd validate this function before it ships into the alerting pipeline. For each case, say what input you'd use, what you expect, and why that case matters given where this function is used. You don't need to write real code, just describe each test precisely enough that someone else could implement it exactly as you mean it.