import random


def attack(health, power, percent_to_hit):
    """Calculates health from percent to hit and power of hit

    Parameters:
        health - integer defining health of attackee
        power - integer defining damage of attacker
        percent to hit - float defining percent chance to hit of attacker

    Returns: new health
    """
    random_number = random.random()  # number between 0.0 and 1.0
    # if our random number falls between 0 and percent to hit
    if random_number <= percent_to_hit:
        # then a hit occurred so we reduce health by power
        health = health - power
    # return the new health value
    return health