School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,212 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,599 people online right now. Registration is fast and FREE... Join Now!




TypeError: 'str' object is not callable

 

TypeError: 'str' object is not callable

EasyToYog

6 Oct, 2009 - 10:09 AM
Post #1

New D.I.C Head
*

Joined: 24 Jan, 2008
Posts: 5

Hi, I'm new to python and I ran into this error
CODE

Traceback (most recent call last):
  File "<string>", line 1, in <string>
TypeError: 'str' object is not callable

Here is my code:
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)


User is offlineProfile CardPM
+Quote Post


shadhin

RE: TypeError: 'str' Object Is Not Callable

6 Oct, 2009 - 08:51 PM
Post #2

D.I.C Regular
Group Icon

Joined: 16 Sep, 2008
Posts: 434



Thanked: 19 times
Dream Kudos: 3650
My Contributions
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-
CODE

print "Your Ontario Tax Credit is: %s$" %(Line5820 + line5808 + line24)

And let me know if you are getting desired result or not.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 09:43PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month