#function problem beginner question

1 messages · Page 1 of 1 (latest)

sage hedge
#

im getting this instead of the numbers i need to get

Cost of item: 0
Total: 65637.0
Sales tax: <function taxAmount at 0x000001F6357DD580>
Total after tax: <function afterTax at 0x000001F6357DD6C0>
Again? (y/n):)

i played around with it for over an hour and im tired help please

from TaxModule import taxAmount, afterTax

def title():
    print("Sales Tax Calculator")

def menu():
    print("ENTER ITEMS (ENTER 0 TO END)")

def main():
    title()
    menu()
    done = False
    totalSum = 0
    while not done:
        try:
            choice = float(input("Cost of item: "))
            if choice != 0:
                totalSum += choice
                print(totalSum)
                continue
            elif choice == 0:
                done = True
        except ValueError:
            print("please enter a number")
    print(f"\tTotal: {totalSum}")
    print(f"\tSales tax: {taxAmount}")
    print(f"\tTotal after tax: {afterTax}")
    choice = input("Again? (y/n):)")
    while True:
        try:
            if choice == ("y"):
                menu()
            elif choice == ("n"):
                print("Thanks, bye!")
                exit()
        except ValueError:
            print("Please enter (y/n)")
            continue

main()```

this is the module
```py
def tax():
    6

def taxAmount():
    return totalSum * tax / 100

def afterTax():
    return taxamount+totalSum


    
rigid heron
#

When you see <function it means you didn't call the function

glacial thorn
#

You need to call the function

#

and pass the parameters to it

sage hedge
#

huh i thought I was calling it when i tried printing it

rigid heron
#

You need () after the function name in order to call it

sage hedge
sage hedge
#

is it the paremeters?

rigid heron
#

Can you show the full error message

sage hedge
#

Traceback (most recent call last):
File "C:/Users/Erico/OneDrive/Desktop/new homework/SalesTaxCalculator.py", line 40, in <module>
main()
File "C:/Users/Erico/OneDrive/Desktop/new homework/SalesTaxCalculator.py", line 25, in main
print(f"\tTotal: {totalSum()}")
TypeError: 'float' object is not callable

glacial thorn
#

not a function

sage hedge
#

wait but i dont have a variable with that name

rigid heron
glacial thorn
#

totalSum = 0

sage hedge
#

sry im slightly dyslexic i read something different lmao

#

Traceback (most recent call last):
File "C:/Users/Erico/OneDrive/Desktop/new homework/SalesTaxCalculator.py", line 40, in <module>
main()
File "C:/Users/Erico/OneDrive/Desktop/new homework/SalesTaxCalculator.py", line 26, in main
print(f"\tSales tax: {taxAmount(totalSum)}")
File "C:\Users/Erico/OneDrive/Desktop/new homework\TaxModule.py", line 5, in taxAmount
return totalSum * tax / 100
TypeError: unsupported operand type(s) for *: 'float' and 'function'

#

--

rigid heron
#

You didn't call your function

sage hedge
#

the tax funtion?

#

got it
i understand the calling function now, there was another mistake that was overlapping with it so i got even more lost for a bit lol
thanks for the help