[Tutor] Is this correct?
cclpianos at comcast.net
cclpianos at comcast.net
Sun Feb 8 16:24:06 CET 2009
HI,
I just realized that I shouldn't enclose my project in an attachment.
This is my first attempt to string together py-code. Is this correct?
And how would a pro word this? It seems like an awful lot of code
for such a small task.
Thanks in advance,
Pat
/////////////////////////////////////////////////////////////
# Problem Set 1
# Name P Wethington
# Collaborators :None
# Time #1:00
# This is a program intended to compute the number of students who
will benefit from a grant, also what
# amount the last student will receive. One grant is given every
other year until the funds run out.
principal = 500000 # Starting fund amount.
balance = principal
interestRate = .05 # Interest rate added to the principal annaully.
tuition = -34986 # Starting tuition fee
tuitionInc = .041# The annual increase applied to the tuition.
count = 0 # keeps me informed on the number of students benefitting
from this grant.
if count == 0:
print principal, "Is the starting principal" # This is to
show the starting balance.
print -tuition, "Is the starting tuition."
print principal + tuition," the amount remaining after first
tuition deduction. "
balance = principal + tuition
count = count + 1
if count ==1:
newPrincipal = (balance * interestRate) # calculates the
amount added to the fund
print newPrincipal," Interest added to fund for one year. "
print balance + newPrincipal, "is the new balance."
count = count + 1
newBalance = balance + newPrincipal
while principal > 0 + -tuition:
if count > 1:
newTuition = (tuition * tuitionInc) #calculates the
rising cost of tuition.
tuition = tuition + newTuition
if newBalance < -tuition:
print newBalance + newPrincipal
newBalance = principal
print principal," is the new balance. "
newPrincipal = (principal * interestRate)
print newPrincipal," is the new interest on
the principal. "
print principal + newPrincipal,"is the new
principal. "
balance = principal + newPrincipal
newTuition = (tuition * tuitionInc) #calculates the
rising cost of tuition.
tuition = tuition + newTuition
print -tuition," is the new cost of tuition. "
principal = newBalance + tuition
print principal," is the new balance. "
newPrincipal = (principal * interestRate)
print newPrincipal," is the new interest on the
principal. "
print principal + newPrincipal,"is the new principal. "
balance = principal + newPrincipal
count = count + 1
if -tuition > principal:
print principal + newPrincipal, "was available for
the last student."
if count > 10:
print count, "Students used this grant."
More information about the Tutor
mailing list