Assume that the grades one has are:
import numpy as np #import numpy
assignments = [100, 100, 100, 30, 90, 50, 100, 0, 75, 80] #assignment marks
final = 70 #final exam mark
extra = 500/1200*40 #percent of your final mark that is 100 due to extra credit
print('percentage of final mark that is 100 due to extra credit: ', extra)
percentage of final mark that is 100 due to extra credit: 16.666666666666668
#replace assignment marks that are below the final mark with the final mark.
new_assignments = np.where(assignments > np.array(final), assignments, final)
#Print out new assignments to make sure they are sensible.
print('New assignment grades after replacement with Final', new_assignments)
print('old assignment average:', np.mean(assignments))
print('new assignment average:', np.mean(new_assignments))
New assignment grades after replacement with Final [100 100 100 70 90 70 100 70 75 80] old assignment average: 72.5 new assignment average: 85.5
#The overall mark is 20% from the final exam/project and 80% from the (revised) assignments
mark = .2*final + .8*np.mean(new_assignments)
#However, 50/1200 percent of the mark is a 100% due to the extra credit.
adjusted_mark = extra + (1-extra/100)*mark
print('mark without extra credit: ', mark)
print('mark with extra credit: ', adjusted_mark)
mark without extra credit: 82.4 mark with extra credit: 85.33333333333334