Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cascade
y3 = [86,90,90,68,86,79,79,78,61,62,45,60]
y2 = [81,81,79,79,77,73,55,55,86,84,83,81]
# 8 modules per band
BAND_SIZE = 8
BAND_DELTA = len(y3) - BAND_SIZE
# Extract BAND_SIZE best year 3 modules
y3_sorted = sorted(y3)
band_3 = y3_sorted[-BAND_SIZE:]
# Init band_2 with remaining year 3 modules
band_2 = y3_sorted[:-BAND_SIZE]
# Populate remaining slots (BAND_DELTA) of band_2
y2_sorted = sorted(y2)
band_2.extend(y2_sorted[-BAND_DELTA:])
# band_1 contains whatever is left
band_1 = y2_sorted[:-BAND_DELTA]
# Calculate the average and weighted average for each band
bands = [band_1, band_2, band_3]
def handle_band(band, weight):
avg = float(sum(band)) / len(band)
wavg = avg * weight
return avg, wavg
print("Band\tAvg.\tW.Avg.")
total = 0
for i, band in enumerate(bands):
band_no = i+1
avg, wavg = handle_band(band, band_no)
total += wavg
print("%d\t%.2f\t%.2f" % (band_no, avg, wavg))
print("Degree Result: %.2f" % (total/6))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.