Interview prep
24 Jupyter interview questions, with answers.
Jupyter Notebook and JupyterLab questions for data roles: kernels, hidden state, magics, environments, version control and when a notebook should become real code.
Almost every data scientist uses Jupyter, so interviewers use it to tell everyday users from people who understand what's underneath. Expect questions on kernels and hidden state, magic commands, getting packages into the right environment, and how you make a notebook reproducible and reviewable.
The best answers show judgement: what notebooks are great for, where they go wrong, and when you'd move code into a module.
These 24 questions are free. SchoolWhool's Foundations of AI course places 650+ interview questions right after the lessons they test, with a mock interview with Gaurav. See also the machine learning interview questions.
Notebook basics
What is Jupyter, and how is Jupyter Notebook different from JupyterLab?
.ipynb files and kernels.What is inside an .ipynb file?
How do IPython and Jupyter relate?
ipykernel) is what runs Python code in Jupyter. Jupyter grew out of IPython in 2014 to become language-agnostic, which is where the name (Julia, Python, R) comes from. Magic commands, rich display and tab completion come from IPython.What's the difference between code, markdown and raw cells?
What are command mode and edit mode? Name a few shortcuts.
Kernels and execution
What is a kernel?
ipykernel), R and Julia.What does restarting the kernel do, and when should you do it?
What problems does out-of-order execution cause?
How do you use a virtual environment or conda environment as a kernel?
ipykernel in that environment and register it: python -m ipykernel install --user --name myenv --display-name 'Python (myenv)'. Then choose it from the kernel menu. A common mistake is installing packages into a different environment from the one the kernel runs in.Why use %pip install instead of !pip install?
%pip installs into the environment of the running kernel. !pip runs whichever pip comes first on the shell's PATH, which may belong to a different Python, so the import still fails. The same goes for %conda. Restart the kernel if the package was already imported.How do you interrupt or debug a cell?
KeyboardInterrupt in the kernel. After an exception, %debug opens the post-mortem debugger at the failing line, and %pdb on does it automatically. JupyterLab also has a visual debugger with breakpoints.Magics and tools
What are magic commands? What's the difference between line and cell magics?
% and apply to one line (%timeit, %run, %load_ext); cell magics start with %% and apply to the whole cell (%%time, %%writefile, %%bash). %lsmagic lists them all. Because they aren't valid Python, they break if you export a notebook to a script and run it with python.%time or %timeit?
%time runs the code once and reports wall-clock and CPU time, which suits slow, one-off steps. %timeit runs a statement many times and reports the mean and spread, which suits small snippets. Keep setup, such as loading data, out of the timed code.What does %autoreload do?
%load_ext autoreload and %autoreload 2, imported modules are reloaded before each cell runs, so edits to your .py files take effect without restarting the kernel. It's ideal once you've moved code out of the notebook into modules. It isn't perfect: existing objects keep old class definitions, so restart if behaviour looks strange.How do you display plots in a notebook?
%matplotlib inline makes it explicit. %matplotlib widget (the ipympl package) gives interactive zoom and pan. Plotly, Altair and Bokeh render interactive HTML outputs directly.What are ipywidgets for?
interact(f, x=(0, 10)) turns a function into a small explorer. They're great for exploring parameters and for demos. For an app other people use, Voilà, Streamlit or Panel are better fits.How do you reuse code from another notebook?
%run other.ipynb executes it in the current namespace, which works but hides where names come from. The better habit is to move shared functions into a .py module and import them, which also makes them testable.Reproducibility and production
How do you make a notebook reproducible?
How do you put notebooks under version control?
.ipynb diffs are noisy because outputs and metadata change. Strip outputs before committing (nbstripout as a pre-commit hook), use nbdime for notebook-aware diffs and merges, or pair each notebook with a plain script using Jupytext and review that in pull requests. Never commit secrets that were printed in an output.How do you run a notebook from the command line or on a schedule?
jupyter nbconvert --to notebook --execute report.ipynb runs it and saves the outputs. Papermill adds parameters, via a cell tagged parameters, and saves an executed copy for each run, which is handy for scheduled reports. Anything long-lived belongs in scripts or a pipeline tool.Should notebooks be used in production?
How do you test code that lives in notebooks?
assert statements on shapes and values are a quick sanity check inside the notebook.What security risks come with notebooks?
How do you work with data that's too big for the notebook's memory?
del on large objects, or use DuckDB, Polars or Dask. Huge printed outputs also bloat the notebook file, so print summaries, not whole tables.Keep preparing
26 pandas interview questions
pandas interview questions on indexing, cleaning, groupby, merges, reshaping and performance, including the warnings and silent bugs interviewers love to ask about.
Interview prep23 data visualization interview questions
Data visualization interview questions with answers: choosing the right chart, honest design, matplotlib, seaborn and plotly, and the plots that matter when you build and evaluate models.
ArticlePython for machine learning and AI: what to learn first, and what to skip
Learn core Python first, then NumPy, pandas, Matplotlib and scikit-learn, in that order. What each stage gives you, what to skip and when you know enough.
Interview prep28 Python interview questions
Python interview questions for data science, ML and backend roles: mutability, data structures, functions and scope, classes, generators, errors and the GIL, with the pitfalls interviewers probe.
ArticleMachine learning code in Python: a first model in about 30 lines, plus two more examples
Runnable machine learning sample code in Python: a scikit-learn classifier explained line by line, plus regression and clustering, each with its output.
ArticleLogistic regression from scratch: fit probabilities and inspect errors
Implement stable binary cross entropy and its gradient in NumPy, train on invented data and compare held-out predictions with a constant baseline.
First Principles, the SchoolWhool newsletter
One machine learning idea, explained properly, every week.
The intuition, the common mistake, and a five-minute way to try it yourself. Written by Gaurav.
Learn it properly, then the interview is the easy part.
Foundations of AI teaches Jupyter and the rest of machine learning from first principles, with notebooks that check your work.