Kodewick
开始学 →
基础←→0 / 100

加上小费

#072基础函数数字约 4 分钟

餐厅结账要加小费。写 with_tip(bill, percent),返回账单加上 percent% 小费以后的钱,用 round 保留 2 位小数。不说 percent 的时候默认是 10。

示例
with_tip(50)→55.0
with_tip(80, 15)→92.0
main.py
# 在这里写:percent 默认是 10
def with_tip(bill, percent):
    # 在这里写:小费是 bill × percent / 100
    tip = 0
    return round(bill + tip, 2)
Ctrl + Enter 也能运行
结果

写好了先点「运行」试试示例,没问题再点「提交」。