I want to create a weighting function in Python. However the amount of weighting varies and I need the function to have optional parameters (for instance, you could find the cost of weightA
and weightB
, but you could also find all of the above.
The basic function looks like this:
weightA = 1
weightB = 0.5
weightC = 0.33
weightD = 2
cost = 70
volumeA = 100
volumeB = 20
volumeC = 10
volumeD = 5
def weightingfun (cost, weightA, weightB, volumeA, volumeB):
costvolume = ((cost*(weightA+weightB))/(weightA*volumeA+weightB*volumeB))
return costvolume
How can I change the function so that I could for example also weight volume C and volume D?
Thanks ahead!