← All Python interview questions

Median salary without using a library

EasyStatisticsTCSInfosys

A salary benchmarking sheet has a few very large outliers, so the mean is misleading. You need the median instead — and the interviewer wants it implemented by hand.

Write a function median(values) that returns the median of a list of numbers as a float, without importing statistics or numpy. Return None for an empty list.

Practising alone only goes so far — our live cohorts pair Python and Pandas depth with dashboards, agentic analytics projects and mock interviews.

Explore the program