Sunday, December 16, 2012

How to Find the Best Deal on Tuition

I'm attending school this fall. Finally! I am using my own money to pay for it. So, looking at this page, I wanted to find the best deal on credits:


http://opb.washington.edu/content/tuition-and-required-fees?year=2012-13&qtr=2&campus=0&category=1&res=1&submit=Submit

I wanted to know which amount of credits had the most value per dollar. I started writing a program. At first, I had the user enter the tuition rates manually. But, in testing, that became tedious. So I copied the data -- total amount in the rightmost column -- from the web page into a text file. Each amount was on a separate line, like so:

883
1289
1695
2101

Here is what I ended up writing today:

f = open('uw_tuition_rates.txt', 'r')
    
credits = 2

rates = []
for q in f.read().split():
    rates.append(int(q))
f.close()

x = rates[0]
y = rates[1]

while y != 0:
  print ("Tuition rate:", y)
  credits = credits + 1
  print ("Credits: ", credits)
  print ("difference: ", y - x)
  print ("ratio: ", y/credits, "dollars per credit")
  print ()
  x = y
  y = rates[credits-1]

If you run this code as a module, each amount is listed along with the number of credits it pays for. The difference between this amount and the previous amount is displayed. Finally, the desired information (the best deal!) is found on the "ratio" line. So as you can see, tuition from 10-18 credits is a flat rate of 4131. Therefore, 18 credits is the best value. But what wasn't apparent on the web page was that the amount of credits above 18 all have better value than credits below 15. In other words, even though 12 credits are the same price as 10 credits, 20 credits is cheaper than both.