<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def zoom_for_pixelsize(pixel_size, max_z=24, tilesize=256):
 """ Get mercator zoom level corresponding to a pixel resolution. Freely adapted from https://github.com/OSGeo/gdal/blob/b0dfc591929ebdbccd8a0557510c5efdb893b852/gdal/swig/python/scripts/gdal2tiles.py#L294 Parameters pixel_size: float Pixel size max_z: int, optional (default: 24) Max mercator zoom level allowed tilesize: int, optional Mercator tile size (default: 256). Returns ------- Mercator zoom level corresponding to the pixel resolution """

    for z in range(max_z):
        if pixel_size > _meters_per_pixel(z, 0, tilesize=tilesize):
            return max(0, z - 1)  # We don't want to scale up

    return max_z - 1