美好的一天,我是新手,我需要幫助!
print("Welcome to the tip calculator!")
bill = float(input("What was the total bill? $"))
tip = int(input("What tip should we give? 12, 15, 20? "))
people = input("How many people are spliting the bill? ")
total_bill = (f"{bill} * {tip / 100} / 5")
print(total_bill)
唯一運行的符號是大括號中的符號。我已經嘗試了各種線路來完成它,但沒有運氣。唯一有效的時候是我直接保持在小費(0.12)中。甚至不記得怎么了..請幫忙!
uj5u.com熱心網友回復:
當我使用 bill = 120、tip = 15、people = 4 運行您的代碼時,我得到:
120.0 * 0.15 / 5
除了您不在代碼的其余部分中使用“人”這一事實之外,您為什么不這樣做:
total_bill = int(bill)*(1 int(tip)/100)
bill_per_person = total_bill/int(people)
print('The total bill is $', str(total_bill), 'and each person needs to pay $', str(bill_per_person))
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/491185.html
上一篇:分割有理貝塞爾曲線
