1 Replies - 7110 Views - Last Post: 06 October 2009 - 09:51 PM Rate Topic: -----

#1 EasyToYog  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-January 08

TypeError: 'str' object is not callable

Post icon  Posted 06 October 2009 - 11:09 AM

Hi, I'm new to python and I ran into this error
Traceback (most recent call last):
  File "<string>", line 1, in <string>
TypeError: 'str' object is not callable


Here is my code:
def medical_amount(d_net_income, med_expenses):
	'''Return the deductible amount to be entered on line 5816 of the 
	   Ontario Tax form, based on float d_net_income, the dependant's net income.
	'''
	temp = med_expenses - min(1965, d_net_income * 0.03)

	if temp < 0:
		return 0
	elif temp > 10591:
		return 10591
	else:
		return temp

def age_amount(net_income):
	'''Return the amount to be entered on line 5808: "Age amount", of the
	   Ontario Tax Form, based on float net_income, the taxpayer's net income. 
	   This credit applies only to persons born in 1943 or earlier.
	'''
	temp = 4329 - (net_income - 31554) * 0.15
	
	if temp < 0:
		return 0
	else:
		return temp
	
def infirm(d_net_income):
	'''Returns the amount to be entered on line 5820: "amount for dependants age
	   18 or older". based on float net_income, the taxpayer's net income.
	'''
	temp = 9908 - d_net_income
	
	if temp < 0:
		return 0
	elif temp > 4091:
		return 4091
	else:
		return temp

def political_amount(contribution):
	'''Returns the amount to be entered on line 24 based on contribution.
	   There are 4 possible conditions and each have to do a different form.
	'''
	if contribution >= 336:
		return contribution * 0.75
	
	elif 336 < contribution < 1120:
		return (contribution - 336) * 0.5 + 252
	
	elif 1120 < contribution < 2548:
		return (contribution - 1120) * 0.3333 + 644
	
	else:
		return 1120
	
if __name__ == "__main__":
	net_income = float(raw_input("Please enter your net income:"))

	d_net_income = float(raw_input("Please enter dependant's net income:"))
	
	med_expenses = float(raw_input("Please enter dependant's medical expenses:"))
	
	answer = raw_input("Is the dependant infirm(please enter 'yes' or 'no'):")
	if answer == "yes":
		Line5820 = infirm(d_net_income)
	else:
		Line5820 = 0
		
	answer = int(raw_input("Please enter the year you were born(all four digits):"))
	if answer < 1944:
		line5808 = age_amount(net_income)
	else:
		line5808 = 0
	
	contribution = float(raw_input("Please enter the amount of your political contributions:"))
	line24 = political_amount(contribution)
	
	print "Your Ontario Tax Credit is: $" (Line5820 + line5808 + line24)



Is This A Good Question/Topic? 0
  • +

Replies To: TypeError: 'str' object is not callable

#2 atik97  Icon User is offline

  • ???
  • member icon

Reputation: 144
  • View blog
  • Posts: 715
  • Joined: 16-September 08

Re: TypeError: 'str' object is not callable

Posted 06 October 2009 - 09:51 PM

I haven't gone truogh the logic of the program, just checked the line causing error.Take a look at the last line of your program and replace it with-
print "Your Ontario Tax Credit is: %s$" %(Line5820 + line5808 + line24)


And let me know if you are getting desired result or not.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1