PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Data Manipulation (SQL/Python)/OpenAI

Debug and harden trial-assignment Python code

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of experiment assignment, data integrity, reliability engineering, concurrency, observability, and privacy in data systems, testing competencies around randomness, idempotency, time semantics, retries, and failure-mode identification.

  • Medium
  • OpenAI
  • Data Manipulation (SQL/Python)
  • Data Scientist

Debug and harden trial-assignment Python code

Company: OpenAI

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

You are given the following simplified Python snippet used to assign users and trigger a 1‑month free trial: """ import random, datetime, requests def maybe_start_trial(user_id): if random.random() < 0.5: variant = 'trial' else: variant = 'control' now = datetime.datetime.now() exposed_at = now log_exposure(user_id, exposed_at, variant) if variant == 'trial': r = requests.post('https://billing/start_trial', json={'user_id': user_id}) if r.status_code == 200: log_trial(user_id, now) """ Identify at least 8 distinct correctness or reliability issues that could corrupt the experiment or data (think assignment stickiness, bias, timezones, idempotency, retries, race conditions, privacy, and observability). For each, explain the failure mode and its impact on metrics. Then propose concrete fixes (e.g., user‑hash bucketing with stable salts, UTC timestamps, exactly‑once exposure logging, outbox/queue, idempotency keys, transactional writes, circuit breakers, exponential backoff, and eligibility checks). Finally, sketch a hardened version (high‑level or pseudocode) that is production‑ready and experiment‑safe.

Quick Answer: This question evaluates understanding of experiment assignment, data integrity, reliability engineering, concurrency, observability, and privacy in data systems, testing competencies around randomness, idempotency, time semantics, retries, and failure-mode identification.

Related Interview Questions

  • Write SQL for repeat churn - OpenAI (hard)
  • Handle repeated churn in SQL - OpenAI (hard)
  • Compute churn with re-subscriptions - OpenAI (hard)
  • Write SQL for post-trial conversion cohorts - OpenAI (Medium)
  • Write SQL to compute signup and retention lift - OpenAI (medium)
OpenAI logo
OpenAI
Oct 13, 2025, 9:49 PM
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
16
0

You are given the following simplified Python snippet used to assign users and trigger a 1‑month free trial:

""" import random, datetime, requests

def maybe_start_trial(user_id): if random.random() < 0.5: variant = 'trial' else: variant = 'control' now = datetime.datetime.now() exposed_at = now log_exposure(user_id, exposed_at, variant) if variant == 'trial': r = requests.post('https://billing/start_trial', json={'user_id': user_id}) if r.status_code == 200: log_trial(user_id, now) """

Identify at least 8 distinct correctness or reliability issues that could corrupt the experiment or data (think assignment stickiness, bias, timezones, idempotency, retries, race conditions, privacy, and observability). For each, explain the failure mode and its impact on metrics. Then propose concrete fixes (e.g., user‑hash bucketing with stable salts, UTC timestamps, exactly‑once exposure logging, outbox/queue, idempotency keys, transactional writes, circuit breakers, exponential backoff, and eligibility checks). Finally, sketch a hardened version (high‑level or pseudocode) that is production‑ready and experiment‑safe.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More OpenAI•More Data Scientist•OpenAI Data Scientist•OpenAI Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.