All pastes #801362 Raw Edit

k4st

public python v1 · immutable
#801362 ·published 2007-11-29 05:30 UTC
rendered paste body
def scholarship_1(amount=15000, skip=4, ir=0.06, sr=0.03, sri=1.03, it=10):	"""Calculate and output the scholarship payouts (among other things)	given an interest rate and a scholarship rate function.		amount	the initial amount of the scholarship	skip	the number of years to skip before the first payment	ir		yearly interest rate	sr		amount to pay out on the first year of scholarship payment	sri		amount to increase the initial scholarship payment by	it		number of iterations of payments to do	"""		total = amount * ((1+ir)**(skip-1))	scholarship = sr * total	# we start from *just* before the fourth year's interest earnings	for n in range(0, it):		interest = ir * total		total = total + interest - scholarship		print "scholarship: %f\ntotal: %f\n\n" % (scholarship, total)				# for next loop		scholarship = sri * scholarship	if __name__ == "__main__":	print "method one: interest calculation, then scholarship, then deduct.\n"	# want: 535.957200	#scholarship_1(it=2)	scholarship_1(it=10, sr=0.08, sri=1.08)