Exemplo n.º 1
0
def main():
    """
    1) Get necessary parameters from the user.
    2) Calculate the mixture.
    3) Output the results.
    """
    abv1 = decimal.Decimal(Cli.arg(*PROMPT_LIST))  # pylint: disable=star-args
    abv2 = decimal.Decimal(Cli.arg(*PROMPT_LIST))  # pylint: disable=star-args
    target_abv = decimal.Decimal(Cli.arg(*PROMPT_LIST))  # pylint: disable=star-args

    # If it is possible to create a mixture according to the provided
    # parameters,
    # find and output the answer.
    if (target_abv >= abv1 or target_abv >= abv2) and (target_abv <= abv1 or target_abv <= abv2):
        target_vol = decimal.Decimal(Cli.arg(*PROMPT_LIST))  # pylint: disable=star-args

        vol1 = target_vol * (target_abv - abv2) / (abv1 - abv2)
        vol2 = target_vol - vol1
        print("\nYou will need {:4.3} fl. oz. of the first ingredient ({}% ABV), and".format(vol1, abv1))
        print("\t      {:4.3} fl. oz. of the second ingredient ({}% ABV).\n".format(vol2, abv2))

    # Otherwise, apologize to the illogical user.
    else:
        print("Sorry, that's not possible.")  # pylint: disable=C0325