它不会打印出我想打印的东西

时间:2019-05-16 15:08:51

标签: python

我做了我能做的一切,但它无法打印出我想要的东西,但它刚出来 “电子售票自动化系统 成人人数:3 孩子人数:3 老人人数:3 什么样的会员资格1公司会员或2家庭会员:1 输入的信息有误,请重新输入以上信息。

以退出代码0“完成的过程

DEBIAN_FRONTEND=noninteractive apt-get -y update
DEBIAN_FRONTEND=noninteractive apt-get -y build-essential curl libcurl4 libcurl4-openssl-dev ruby-full gem

1 个答案:

答案 0 :(得分:0)

我想您忘记了将变量membership的输入视为int

这是更新的源代码,

print("E Ticketing Automation System")

#a for adult b for kids and c for elderly
a = int(input("Numbers of adult: "))
b = int(input("Numbers of kids: "))
c = int(input("Numbers of elderly: "))
membership = int(input("what kind of membership 1 for corporate  or 2 for family: "))

totalprice = (a*10.00) + (b*7.50) + (c*5.50)
kiddo=b*7.50


corporate = totalprice-(totalprice/100)*20
ccorporate=(totalprice/100)*20
family = totalprice-(b*7.50)


if membership == 1:
   print("The original price before discount is $,",totalprice,"after 20 percent discount",ccorporate, "the total price will be $",corporate, )
elif membership == 2:
   print("The original price is $",totalprice,"but after deduction of the kids price $",kiddo,"the total price will be $",family,)
else:
   print("there is information inputted incorrectly pls re-enter the info above.")

预期输出:

E Ticketing Automation System
Numbers of adult: 3
Numbers of kids: 3
Numbers of elderly: 3
what kind of membership 1 for corporate  or 2 for family: 1
The original price before discount is $, 69.0 after 20 percent discount 13.799999999999999 the total price will be $ 55.2