Question

In: Computer Science

def stateTax(amount): taxRate = 0.05 taxAmount = taxRate * amount print('State tax: ',taxAmount) return taxAmount def...

def stateTax(amount):
taxRate = 0.05
taxAmount = taxRate * amount
print('State tax: ',taxAmount)
return taxAmount

def countyTax(amount):
taxRate = 0.025
taxAmount = taxRate * amount
print('County tax: ',taxAmount)
return taxAmount

def totalTax(state,county):
taxAmount = state + county
print('Total tax: ',taxAmount)
return taxAmount

def totalAmount(amount, tax):
total = amount + tax
return total
def main():
amount = float(input('Enter the amount of purchase: '))
sTax = stateTax(amount)
cTax = countyTax(amount)
tTax = totalTax(sTax,cTax)
print('Total amount including tax is: ' ,total)

main()

I am a student using python programing.

My goal is to

1. Enter purchase amount

2. Compute State tax

3. Compute County tax

4. Display purchase amount

5. Display state tax

6. Display county tax

7. Display total sales tax

8. Display Total of Sale

How can I fix my line 26 to define total from error saying total is not defined?

Solutions

Expert Solution

Correct code:


# Calculates stateTax and returns stateTax amount
def stateTax(amount):
taxRate = 0.05
taxAmount = taxRate * amount
print('State tax: ',taxAmount)
return taxAmount

# Calculates countyTax and returns countyTax amount
def countyTax(amount):
taxRate = 0.025
taxAmount = taxRate * amount
print('County tax: ',taxAmount)
return taxAmount

# Calculates sum of stateTax and countyTax returns Total Tax amount
def totalTax(state,county):
taxAmount = state + county
print('Total tax: ',taxAmount)
return taxAmount

# Calculates sum of purchase and tax and returns total sale
def totalAmount(amount, tax):
total = amount + tax
return total
def main():
amount = float(input('Enter the amount of purchase: '))
sTax = stateTax(amount) ## State Tax is stored in sTax
cTax = countyTax(amount) ## Country Tax is stored in cTax
tTax = totalTax(sTax,cTax) ## Total Tax is stored in sTax
  
# calling totalAmount function by passing purchase amount and total tax
tSale = totalAmount(amount,tTax)## Total sale is amount is stored in tSale
print('Total amount including tax is: ' ,tSale)

main()

OUTPUT:

ERRORS YOU MADE:

  • variable total is not there in function main. It is the function totalAmount.
  • Moreover total is the return value in the function totalAmount. You have to use another variable to store the total value.
  • Next you didn't call the function totalAmount in main().

Related Solutions

Using Python def specialAverage():    Print the number of 0s and then return the average of...
Using Python def specialAverage():    Print the number of 0s and then return the average of either the positive values in the list (if the optional parameter has value 1) or the negative values in the list (if the optional parameter has value 0).    Arguments: a list of numbers : the list can contain any numeric values an integer : this integer is an optional parameter and only takes value 0 or 1, and defaults to 1 if the...
How do state estate tax payment or state death tax payment affect the estate tax return...
How do state estate tax payment or state death tax payment affect the estate tax return The amount of tax paid is excluded from the gross estate The amount of tax paid is a deduction from the gross estate The amount paid is a credit against the estate tax They do not effect the estate tax return
how do state estate tax payments or state death tax payments affect the estate tax return
how do state estate tax payments or state death tax payments affect the estate tax return
def annoying_valley(n): if n == 0: print() elif n == 1: print("*") elif n == 2:...
def annoying_valley(n): if n == 0: print() elif n == 1: print("*") elif n == 2: print("./") print("*") print(".\\") elif n == 3: print("../") print("./") print("*") print(".\\") print("..\\") elif n == 4: print(".../") annoying_valley(3) print("...\\") elif n == 5: print("..../") annoying_valley(4) print("....\\") elif n == 6: print("...../") annoying_valley(5) print(".....\\") else: print("." * (n - 1) + "/") annoying_valley(n - 1) print("." * (n - 1) + "\\") def annoying_int_sequence(n): if n == 0: return [] elif n == 1: return...
import sys var = 1 print(var) def function1(myVar):     print(myVar)     var = myVar + 1...
import sys var = 1 print(var) def function1(myVar):     print(myVar)     var = myVar + 1     print(var)     function2(var) def function2(myVar):     print(myVar)     var = myVar + 1     print(var)     function3(var) def function3(myVar):     print(myVar)     var = myVar + 1     print(var) def main(argv):     var = 10     print(var)     function1(var) if __name__=="__main__":     main(sys.argv) 1. As the program runs, what is the first line that will be interpreted by Python, and what action will...
a-Define Internal rate of return and state whether it is a dollar amount of a percentage...
a-Define Internal rate of return and state whether it is a dollar amount of a percentage rate? b- what is capital recovery cost? c- you wish to endow a scholarship for student to receive 10,000 each year. The program will last for a very long time. you expect to generate an average intrest rate of 12% per year. Ignoring administrative expenses what is the governing equation to analyze this situation? what amount must you deposit at t=0 to fund such...
import random #the menu function def menu(list, question): for entry in list: print(1 + list.index(entry),end="") print(")...
import random #the menu function def menu(list, question): for entry in list: print(1 + list.index(entry),end="") print(") " + entry) return int(input(question)) plz explain this code
What amount should Weber use as state and local income taxes in calculating itemized deductions for his 2018 Federal income tax return?
Weber resides in a state that imposes a tax on income. The following information relating to Weber's state income taxes is available:State income taxes withheld in 2018$3,000State sales taxes paid$650Refund received in 2018 for 2017 tax$300Assessment paid in 2018 for 2016 tax$800What amount should Weber use as state and local income taxes in calculating itemized deductions for his 2018 Federal income tax return?a.$3,800b.$3,500c.$3,000d.$2,700e.None of these choices are correct.
What amount can Allen deduct as an itemized deduction on his tax return?
Allen paid the following taxes this year:Property taxes on rental property he owns$4,000Property taxes on his own residence3,600Estimated Federal income taxes paid in 20198,000California State income taxes withheld from paycheck  3,400Estimated California Income Taxes paid in 2019500What amount can Allen deduct as an itemized deduction on his tax return?Select one:a. $19,500b. $10,000c. $11,500d. $7,500
Taxable income refers to the amount of income reported on a? company's tax return. True or...
Taxable income refers to the amount of income reported on a? company's tax return. True or false?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT