def hex_to_rgb(color: str, opacity: float = 1) -> str:
    """
    Returns a color in format rgba (red, green, blue, alpha/opacity) for the color given in hex format (#rrggbb).
    :param color: str. Color in format #rrggbb.
    :param opacity: int. Opacity value in range [0, 1].
    :return: str. String in the format rgba.
    """
    color = color.lstrip("#")
    len_color = len(color)
    rgb = tuple(int(color[i:i + len_color // 3], 16) for i in range(0, len_color, len_color // 3))
    rgb_opacity = rgb + (opacity,)

    return "rgba" + str(rgb_opacity)