Mario Garcia
Tutorial

Python Exercises Generate Iteratively with AI for Interview Prer

Why and how I created my own Python Class with exercises for interview prep and DS mind muscle building.

October 5, 2025
26 views
AIPythonData Science

200 Python Exercises Generated Iteratively with Claude Code

Introduction

As part of my interview prep journey, I needed to practice my Python skills and statistical concepts. Instead of spending dozens of dollars on interview prep platforms or prompting AI for exercises one by one, I decided to scale up my AI‑generated Python questions and create a database of 200 Python exercises I can use to practice.

This database was created with Data Scientists in mind, covering topics relevant to day‑to‑day tasks, less frequent but important work, and deeper technical knowledge that comes up from time to time (we need to flex these muscles now and then, friends).

Hopefully, you'll find this as useful as I have.

What Is Included

200 Python coding exercises, many of which aren’t just about writing functions or wrangling data, but about performing actual DS professional tasks. They’re not meant only to prep you for a Python coding interview; they also help you refresh concepts that are paramount for us to know as professionals. The topics included are:

Topics & Subtopics (200 Python Exercises)
topicsub_topictopic_difficulty
data manipulationDataFrame creation and inspectionbeginner
data manipulationFiltering with boolean masksbeginner
data manipulationGroupBy aggregationsbeginner
data manipulationJoins and mergesbeginner
data manipulationPivot and meltbeginner
data manipulationDatetime parsing and resamplingbeginner
Expand to show the remaining topics
topicsub_topictopic_difficulty
data manipulationMissing data handling and imputationbeginner
data manipulationWindow functions: rolling and expandingintermediate
data manipulationVectorization vs applyintermediate
data manipulationMemory and performance optimizationexpert
statistics and causal inferenceDescriptive stats and distributionsbeginner
statistics and causal inferenceCLT and sampling distributionsbeginner
statistics and causal inferenceConfidence intervalsbeginner
statistics and causal inferenceHypothesis tests (t and z)beginner
statistics and causal inferencePower analysis and MDEintermediate
statistics and causal inferenceLinear regression (OLS) and diagnosticsintermediate
statistics and causal inferenceLogistic regression and odds ratiosintermediate
statistics and causal inferenceFixed effects and panel regressionintermediate
statistics and causal inferenceDifference-in-differencesexpert
statistics and causal inferencePropensity score methodsexpert
experimentationDefining units and exposurebeginner
experimentationRandomization and hashingbeginner
experimentationSample size and power planningbeginner
experimentationAA tests and SRM checksintermediate
experimentationGuardrail metrics selectionintermediate
experimentationCUPED variance reductionintermediate
experimentationMultiple testing control (FDR)intermediate
experimentationSequential testing and alpha spendingexpert
experimentationClustered and geo experimentsexpert
experimentationSwitchback designs for platformsexpert

How I Built This

I used Claude Code to iterate through multiple combinations of topics and difficulty levels, experimenting with different exercise formats and validation approaches. The iterative process helped refine the exercise structure and ensure comprehensive coverage of Python concepts.

Process

  1. I explained the task and objectives to Claude, fed it the above table of topics and difficulty levels, and asked it to create a set of 15–20 datasets that I could use.

  2. I created a list of tasks, each specifying how many exercises to create given a topic, subtopic, and exercise difficulty:

{ "group_id": 19, "topic": "statistics_and_causal_inference", "subtopic": "Difference-in-differences", "topic_difficulty": "expert", "exercise_count": 9, "difficulty_split": {"hard": 5, "hells_of_flame": 4}, "datasets": ["employee_panel", "geo_experiment", "student_performance"], "id_range": "stat_056 to stat_064" }
  1. I manually asked Claude to go through the groups, executing the tasks (creating exercises following the guidelines).

gif_imagegif_image

  1. Once I had the initial output, I used the Claude API to review each exercise individually—checking for accuracy, appropriate difficulty calibration, and clear problem statements—which improved the overall quality of the exercises.

Instructions

  1. Initialize the instructor (ensure JSON files are in the same directory):
instructor = PythonInstructor()
  1. Get an exercise by topic and difficulty:
exercise = instructor.get_exercise(topic='loops', difficulty='beginner')
  1. Display the exercise prompt:
print(exercise.get('exercise'))
  1. Attempt to solve the problem:
# ... your solution code here ...
  1. View the solution when ready:
print(exercise.get('solution')) print(exercise.get('expl'))

How to Get the Package?

Send me a LinkedIn invite and slide into my DMs!