我的增值税无法获得正确的数字

时间:2017-06-11 19:04:02

标签: python python-2.7

代码运行正常。我在使用增值税部分时遇到问题,例如它会说没有增值税的价格是100英镑然后增值税是20英镑但是当他们加在一起时它赚了153英镑我不确定它从哪里获得 我的第二个问题是,我试图添加一个循环,所以我会问你想要另一个价格,然后如果他们说是,整个程序重新启动

length = int(raw_input("what is the length of all you walls added together? 
"))
while 2 > length or length > 26:
    length = int(raw_input("what is the height of all you walls added 
    together? "))
else:
    print ("okay")
height = int(raw_input("what is the length of all you walls added together? 
"))
while 1 > height or height > 6:
    height = int(raw_input("what is the height of your room? "))
else:
    print ("okay")
area = height*length
paint = raw_input("what paint would you like to use luxury paint, Standard 
quality, Economy quality? ")
if paint == "LP" or "lp" or "luxery paint":
    LP = 2
    answer = LP*area    
if paint == "SQ":
    SQ = 1.25
    answer = SQ*area    
if paint == "EQ": 
    EQ = 0.55
    answer = EQ*area
undercoat = raw_input("would you like an undercoat?")
if undercoat == "yes":
    undercoat = area*0.55
    novat = answer + undercoat
elif undercoat  == "no":
    novat = answer
percentage = (novat/100.00)*20
print percentage
cost = (novat + percentage)
print "Interior Decorator"
print "invoice"
print "the price will be "+ unichr(163) + str(answer) +"(excluding vat)"
print "the vat will be "+ unichr(163) + str(percentage)
print "your grand total is " + unichr(163) + str(cost)

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

关于错误的值:

看到cost = (novat + percentage)。在打印价格时,您不应该使用novat变量而不是answer吗?

关于循环执行另一个执行:

您可以像代码中的示例一样提取方法和循环:

def main_logic():
    # The code you have above

while True:
    main_logic()
    run_again = raw_input("would you like to run again? ")
    if run_again != "yes":
        break