鱼C论坛

 找回密码
 立即注册
查看: 3046|回复: 1

[已解决]Python代码计算税率该怎么写

[复制链接]
发表于 2023-1-17 04:44:28 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
Write a program in Python that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food, then calculate the amounts of a 18 percent tip (i.e., charge * tip_rate) and 7 percent sales tax (i.e., charge * tax_rate). Display each of these amounts and the total (i.e., charge + tip + tax).
用Python编写一个程序,计算在餐馆购买的饭菜的总金额。该程序应该要求用户输入食物的费用,然后计算出18%的小费(即费用*小费率)和7%的销售税(即费用*税率)的数额,显示这些金额中的每一个和总金额(即费用+小费+税)。
最佳答案
2023-1-17 08:22:36
是不是这样的:
money = int(input('请输入食物的总金额:'))
taxmoney = money * 0.18
salestax = money * 0.07

print("费用为:" , money)
print("小费:", taxmoney, '元')
print("税款:", salestax, '元')
print("总金额:", money+taxmoney+salestax, '元')
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2023-1-17 08:22:36 | 显示全部楼层    本楼为最佳答案   
是不是这样的:
money = int(input('请输入食物的总金额:'))
taxmoney = money * 0.18
salestax = money * 0.07

print("费用为:" , money)
print("小费:", taxmoney, '元')
print("税款:", salestax, '元')
print("总金额:", money+taxmoney+salestax, '元')
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-9-24 23:27

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表