Skip to main content
7 of 7
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/

Python tuition calculator

I'm a student learning Python, I made this calculator that will tell you the tuition for the next 5 years at an increase of 3% per year. How can I improve on this and did I do anything that isn't best practice? To revise my new version, Python tuition calculator 2.0

inState = 10000
outState = 24000
profGrad = 40000

years = []
tuitionIncrease = []


i = raw_input('Please input your type of residency, I for in-state, O for out-of-state, and G for graduate: ')


if i == 'I':
    costOfTuition = inState
elif i == 'O':
    costOfTuition = outState
elif i == 'G':
    costOfTuition = profGrad

x = 0
while x != 5:
    intMath = costOfTuition * 0.03
    tuitionIncrease.append(intMath)
    fnlMath = intMath + costOfTuition
    years.append(fnlMath)
    costOfTuition = fnlMath
    x += 1

academicYear1 = "${:,.2f}".format(years[0])
academicYear2 = "${:,.2f}".format(years[1])
academicYear3 = "${:,.2f}".format(years[2])
academicYear4 = "${:,.2f}".format(years[3])
academicYear5 = "${:,.2f}".format(years[4])

academicYear1Inc1 = "${:,.2f}".format(tuitionIncrease[0])
academicYear1Inc2 = "${:,.2f}".format(tuitionIncrease[1])
academicYear1Inc3 = "${:,.2f}".format(tuitionIncrease[2])
academicYear1Inc4 = "${:,.2f}".format(tuitionIncrease[3])
academicYear1Inc5 = "${:,.2f}".format(tuitionIncrease[4])

totalTuitionIncreaseSum = sum(tuitionIncrease)
totalTuitionIncrease = "${:,.2f}".format(totalTuitionIncreaseSum)
4
print('UNDERGRADUATE TUITION FOR THE NEXT FIVE YEARS ')
print('ACADEMIC YEAR          TUITION       INCREASE ')
print('-------------     ------------       -------- ')
print('2016-17             ' + academicYear1 + '        ' + academicYear1Inc1) 
print('2017-18             ' + academicYear2 + '        ' + academicYear1Inc2) 
print('2018-19             ' + academicYear3 + '        ' + academicYear1Inc3)
print('2019-20             ' + academicYear4 + '        ' + academicYear1Inc4)
print('2020-21             ' + academicYear5 + '        ' + academicYear1Inc5)
print('TOTAL TUITION INCREASE              '     + totalTuitionIncrease)
Aaron
  • 347
  • 1
  • 4
  • 11