Я хотел вызвать использовать значение total в первой функции и использовать его в качестве аргумента в двух других функциях. Но, похоже, это не работает, так как вызывает ошибку имени.
def all_total():
'''Calculates and displays the total including
country and s6ales tax'''
total = float(input('Enter the subtotal of the purchase: '))
county_tax(total)
print('County Tax Amount: $'+county_tax())
state_tax(total)
print('State Tax Amount: $'+state_tax())
total += (county_amount + state_amount)
def county_tax(arg1):
'''Calculates the county tax of the total'''
county_tax = float(input('Enter the county tax in percent form: '))
county_amount = county_tax/100*total
return county_amount
def state_tax(arg1):
'''Calculates the state tax of the total'''
state_tax = float(input('Enter the state tax in percent form: '))
state_amount = state_tax/100*total
return state_amount
all_total()
Enter the subtotal of the purchase: 200
Enter the county tax in percent form: .025
Traceback (most recent call last):
File "E:/Bronx Science/Sophomore/Computer Science_Python/Edwin Chen_Lab 9_Sales Tax.py", line 29, in <module>
all_total()
File "E:/Bronx Science/Sophomore/Computer Science_Python/Edwin Chen_Lab 9_Sales Tax.py", line 11, in all_total
county_tax(total)
File "E:/Bronx Science/Sophomore/Computer Science_Python/Edwin Chen_Lab 9_Sales Tax.py", line 20, in county_tax
county_amount = county_tax/100*total
NameError: name 'total' is not defined