def finalvalue(a,b,c,d):
o=round(450-a-(b*2+c+d)*.75+.3)
return ("Impossible, you " if(o)>100 else "You ")+"would need a "+str(o)+"%"
So here I have a function that calculates the weighted score of each of the inputs and what the final score someone will have to earn in order to get at least 90% overall. If the value is NOT an integer, in this case "o", then round to the nearest upper integer. If the score is greater than 100 return a different message with "impossible" instead.
I have already put the return statement with the if clause.
So my question is, how would I optimize this and do this in a fewer lines of code?