餐廳結賬要加小費。寫 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)
寫好了先點「執行」試試示例,沒問題再點「提交」。