Archive | July 2010

Basic Python: Learning Modules

Here’s the source code for a real basic program that I wrote for my Introduction to Programming class at ITT Tech.

#Michael Jenks
#Introduction to Programming
#This program is designed to calculate the state, county, and total taxes
#based off of monthly sales.
def main():
print ‘Welcome to your Monthly Tax Report Calculator’
print
monthlysales = monthly_sales()
countytax = county_tax()
statetax = state_tax()
totaltax = total_tax(countytax, statetax)
print_info(monthlysales, countytax, statetax, totaltax)
print ‘Thank you for using your Monthly Tax Report Calculator’
def monthly_sales():
monthlysales = input(‘What was your monthly sales in dollars?’)
return monthlysales
def county_tax():
countytax = monthlysales * .02
return countytax
def state_tax():
statetax = montlysales * .04
return statetax
def total_tax(countytax, statetax):
totaltax = statetax + countytax
return totaltax
def print_info(monthlysales, countytax, statetax, totaltax):
print ‘Your stated montly sales were:

, monthlysales

print ‘The County taxes are:

, countytax

print ‘The State taxes are:

, statetax

print ‘The total taxes are:

, totaltax

#Michael Jenks#Introduction to Programming
#This program is designed to calculate the state, county, and total taxes#based off of monthly sales.
def main():    print ‘Welcome to your Monthly Tax Report Calculator’    print    monthlysales = monthly_sales()    countytax = county_tax()    statetax = state_tax()    totaltax = total_tax(countytax, statetax)    print_info(monthlysales, countytax, statetax, totaltax)    print ‘Thank you for using your Monthly Tax Report Calculator’
def monthly_sales():    monthlysales = input(‘What was your monthly sales in dollars?’)    return monthlysales
def county_tax():    countytax = monthlysales * .02    return countytax
def state_tax():    statetax = montlysales * .04    return statetax
def total_tax(countytax, statetax):    totaltax = statetax + countytax    return totaltax
def print_info(monthlysales, countytax, statetax, totaltax):    print ‘Your stated montly sales were:

, monthlysales    print ‘The County taxes are:

, countytax    print ‘The State taxes are:

, statetax    print ‘The total taxes are:

, totaltax