2016-03-08 49 views
-6

我的第二個問題是基於服務創建小費計算器。如果服務是驚人的,那麼計算一個20%的提示,如果它可以計算一個15%的提示,並且如果它的可怕計算一個10%的提示。基於服務的小費計算器Python


編輯:從Raj的評論on the other post與他的代碼:

繼承人我做了什麼的問題

rbill = float(input("What is the total bill?")) 
print("What was the level of service?") 
service = input("Please choose amazing, okay, or horrible:") 
while service = amazing: 
    tip=(bill*0.20) 
    total=(bill+tip) 

print("The bill was $",bill) 
print("The service was",service) 
print("The tip is",tip) 
print("The grand total with the tip is $",total) 

- 拉吉3月8日在6:22

+5

拉吉3月8日你覺得這是一個免費的編碼服務或什麼? **不是。** –

+0

我投票結束這個問題作爲題外話,因爲SO不是一項家庭作業完成服務。 – TigerhawkT3

+0

他只是忘記包含他已經寫入帖子的代碼。你可以在http://stackoverflow.com/questions/35860427/python-hw-questions-phone-number的評論中找到它。 :-o – MSeifert

回答

0

代替您在代碼中的while循環:

while service = amazing: 

你應該有

if .. : 

elif ..: 

else: 

語句來替換它,併爲字符串值相等測試時,需要將其設置在引號。下面

if service == "amazing": 

代碼是你(拉吉)對頂部鏈接的其他職位是什麼。我試圖編輯你的問題,但它被拒絕了。下面


代碼從Raj的評論on his other post

繼承人我做了什麼的問題

rbill = float(input("What is the total bill?")) 
print("What was the level of service?") 
service = input("Please choose amazing, okay, or horrible:") 
while service = amazing: 
    tip=(bill*0.20) 
    total=(bill+tip) 

print("The bill was $",bill) 
print("The service was",service) 
print("The tip is",tip) 
print("The grand total with the tip is $",total) 

- 在6:22