我试图用以下信息编写一个计算物业税的程序:
该税是使用评估价值计算的,即实际价值的60%。每100美元的评估价值,72美分被征税。例如,价值10,000美元的财产的分摊价值为6,000美元,总税务费用为43.20美元(6,000/100)*0.72)。
程序的目的是使用函数,因此,虽然下面的程序可能不一定需要函数,但它们是作为函数的介绍性实践而添加的。下面的代码是我想出的。由于无法识别的语法错误,它不会运行。空闲突出第三行,但没有提供其他信息。此代码可能包含几个语法和逻辑错误。
def main():
actual_value = float(input('Enter value of property: ')
calc_assessed_value(actual_value)
def calc_assessed_value(number):
assessed_val = float(number * (6 / 10))
print('The assessed value is equal to 60% of the actual value.')
print('The assessed value for this property is: ', assessed_val)
calc_prop_tax(assessed_val)
def calc_prop_tax(number):
tax_rate = float(0.72)
prop_tax = float(number / 100 * tax_rate)
print('The tax is 72 cents for every $100 of the assesed value.')
print('The total property tax is: $', prop_tax)
main()
发布于 2018-07-23 20:15:45
在第2行中添加一个括号:
def main():
actual_value = float(input('Enter value of property: '))
calc_assessed_value(actual_value)
def calc_assessed_value(number):
assessed_val = float(number * (6 / 10))
print('The assessed value is equal to 60% of the actual value.')
print('The assessed value for this property is: ', assessed_val)
calc_prop_tax(assessed_val)
def calc_prop_tax(number):
tax_rate = float(0.72)
prop_tax = float(number / 100 * tax_rate)
print('The tax is 72 cents for every $100 of the assesed value.')
print('The total property tax is: $', prop_tax)
main()
https://stackoverflow.com/questions/-100005649
复制相似问题