python - 它没有打印出我想打印的东西
问题描述
我做了我能做的,但它不会打印我想要的东西,但它只是出来了“电子票务自动化系统成人人数:3 孩子人数:3 老人人数:3 什么样的会员资格 1 为公司或 2 为家庭: 1 有信息输入错误请重新输入以上信息。
进程以退出代码 0 结束”
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 = 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.")
解决方案
我猜您忘记将变量的输入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
推荐阅读
- javascript - 使用 JS 脚本的单击按钮 (CSS)
- python - 为什么 django 向我显示现有行错误?
- json - 响应中的 Jmeter Key Extraction 值
- sql - 查找具有指定差的所有数字
- python - (Python) 垂直翻转图像下半部分的代码
- javascript - React 没有在 Windows 中被卸载
- firebase - Firebase 控制台中的 Firebase 动态链接后备 URL
- odoo - 在 QWeb 模板中设置布尔属性
- mysql - 使用 Partition By 动态计算比率
- azure-data-explorer - Kusto - Splunk 到 Kusto 查询转换“max(_time) as time by jobid | sort -time”