def format_as_pct(value, decimal=2):
    """
    Formats any value as a percentage.

    Parameters
    ----------
    value : int or float
        The value you want to format as a percentage.
    decimal : int, optional
        The number of decimal places the output should have. The default
        value is 2.

    Returns
    -------
    pct : string
        The value formatted as a string and percentage.

    Examples
    --------
    >>> import pyexample
    >>> pyexample.format_as_pct(0.15678)
    '15.68%'
    >>> pyexample.format_as_pct(0.15678, decimal=1)
    '15.7%'

    """

    fmt = '{0:.%df}%%' % decimal
    return fmt.format(float(value) * 100)