餐厅结账要加小费。写 with_tip(bill, percent),返回账单加上 percent% 小费以后的钱,用 round 保留 2 位小数。不说 percent 的时候默认是 10。
with_tip(50)→55.0with_tip(80, 15)→92.0# 在这里写:percent 默认是 10
def with_tip(bill, percent):
# 在这里写:小费是 bill × percent / 100
tip = 0
return round(bill + tip, 2)
写好了先点「运行」试试示例,没问题再点「提交」。