I'm surprised no-one suggested bisect:
from bisect import bisect
def get_level_of_aqi(aqi):
return bisect([0, 51, 101, 151, 201, 301], aqi)
It strikes me as more elegant and readable than any other solution, and exactly the sort of thing bisect is intended for.