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
Feature Flag Evaluation Engine
00:00
5 left

Feature Flag Evaluation Engine

HardPython

Problem

Given flags.json (flag definitions with key, enabled, default, and rules made of attribute/operator/value conditions), users.json (10,000 users with country, plan, etc.) and expected_decisions.json (answers for 200 users x 7 flags), implement a feature flag evaluation engine: a function to evaluate a single flag for a user and a function to evaluate all flags for a user. Conditions within a rule are ANDed.

Asked in the onsite practical coding stage. Validate against expected_decisions.json first, handle multi-rule conflicts and percentage rollout, then add unit tests.

Use evaluate_flag(flag, user) and evaluate_all_flags(flags, user). A matching rule returns its value; rules are checked in order, and no match returns default. Supported operators are equals, not_equals, in, and not_in. A rule may include percentage, evaluated deterministically from flag.key and user.id.

Constraints

  • Each flag has a unique string key.
  • A flag contains enabled, default, and optionally rules.
  • Conditions within a rule are ANDed.
  • Rules are evaluated in listed order, and the first matching rule wins.
  • Supported operators are equals, not_equals, in, and not_in.
  • Percentage values are integers from 0 through 100.
  • A percentage rule requires user.id.
  • The input dataset contains up to 10,000 users and 7 flags.

Function Signature

def evaluate_flag(flag, user):
Interviewer

Your question is Feature Flag Evaluation Engine. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.