def compound_interest(principal, rate, compounds_per_year, time):
    """Calculates the compound interest earned over a given period of time"""
    principal, rate, compounds_per_year, time = float(principal), float(rate), float(compounds_per_year), float(time)
    return principal * ((1 + ((rate / 100) / compounds_per_year)) ** (compounds_per_year * time))