销售税代码(python)计算

时间:2016-10-30 08:42:36

标签: python

我创建了一个小程序来购买并仅使用功能添加州税和国家税 我面临的问题是如何编辑程序,以便计算税收并显示它们

def main():
    purchase1=float(input("Enter the purchase amount: "))

    return purchase1
def tax(purchase1):
    calculateTax=1.00+0.025+0.05
    return purchase1*calculateTax
def printResult(purchase1,total):
    print("Purchase amount",purchase1)
    print("State Tax Amount 2.5%")
    print("Country Tax Amount 5%")
    print("The Total tax amount is 7.5%")
    print("Your Total is :",format(total))
purchase1=main()
totalTax=tax(purchase1)
printResult(purchase1,totalTax)

我想在打印件(州税和国家税)

之后显示税收的计算

1 个答案:

答案 0 :(得分:0)

你可以这样做:

def main():
    purchase1=float(input("Enter the purchase amount: "))

    return purchase1
def tax(purchase1):
    calculateTax=1.00+0.025+0.05
    return purchase1*calculateTax
def printResult(purchase1,total):
    print("Purchase amount",purchase1)
    print("State Tax Amount 2.5%", purchase1*0.025)
    print("Country Tax Amount 5%", purchase1*0.05)
    print("The Total tax amount is 7.5%", purchase1*0.075)
    print("Your Total is :",format(total))
purchase1=main()
totalTax=tax(purchase1)
printResult(purchase1,totalTax)