def get_dpi_group(dpi):
    # type: (int) -> Density
    """Get viewport density group from given dpi.

    :type dpi: int
    :return: viewport density group enum
    :rtype: Density
    """
    if dpi in range(0, 121):
        return Density.XLOW
    elif dpi in range(121, 161):
        return Density.LOW
    elif dpi in range(161, 241):
        return Density.MEDIUM
    elif dpi in range(241, 321):
        return Density.HIGH
    elif dpi in range(321, 481):
        return Density.XHIGH
    elif dpi >= 481:
        return Density.XXHIGH

    raise AskSdkException("Unknown dpi group value: {}".format(dpi))
Get viewport density group from given dpi.

    :type dpi: int
    :return: viewport density group enum
    :rtype: Density