<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calc_coverage(ref, start, end, length, nucs):
 """ calculate coverage for positions in range start -> end """

    ref = ref[start - 1:end]
    bases = 0
    for pos in ref:
        for base, count in list(pos.items()):
            if base in nucs:
                bases += count
    return float(bases)/float(length)