在扣除Upwork的费用后,我试图计算出总金额。我找到了这网站,但我想用Python来制作它。以下是Upwork的指导方针:
客户收入0-500美元: 20%的服务费适用于收入。500.01-10,000美元的客户收入: 10%的服务费。客户收入10,000.01美元或以上: 5%服务费。
守则:
budget = int(input("Enter the price (USD): $"))
if 0 <= budget <= 500:
cut = int((20/100)*budget)
budget = budget - cut
elif 501.01 <= budget <= 10000:
cut = int((10/100)*budget)
budget = budget - cut
elif budget >= 10000.01:
cut = int((5/100)*budget)
budget = budget - cut
print(f'Total price after Upwork Fee is ${budget}.')根据Upwork的说法,
在一个600美元的项目与一个新的客户,你的自由职业者服务费将是20%的前500美元和10%的其余100美元。你收费后的收入是490美元。
我制作了这个计算器,但它只适用于第一个条件$0-$500 in earnings。如果预算是$600,我会得到$490,但这里我得到$540。有人能帮我找出哪里出了问题吗?
-更新
我也试过了,但没有用:
budget = int(input("Enter the price (USD): $"))
a = 0 <= budget <= 500
b = 501.01 <= budget <= 10000
c = budget >= 10000.01
cut1 = int((20/100)*budget)
cut2 = int((10/100)*budget)
cut3 = int((5/100)*budget)
if a:
cut = cut1
budget = budget - cut
if a and b:
cut = cut2
budget = budget - cut
if a and b and c:
cut = cut3
budget = budget - cut
print(f'Total price after Upwork Fee is ${budget}.')发布于 2022-03-31 06:46:32
budget = int(input("Enter the price (USD): $"))
def discount(money,percent):
cut = int((percent/100)*money)
money= money- cut
return money
if 0 <= budget <= 500:
budget = discount(budget ,20)
elif 500.01 <= budget <= 10000:
budget2 = discount(500 ,20)
budget = discount(budget-500 ,10)
budget = budget + budget2
elif budget >= 10000.01:
budget3 = discount(500 ,20)
budget2 = discount(10000 ,10)
budget = discount(budget-10500 ,5)
budget = budget + budget2 + budget3
print(f'Total price after Upwork Fee is ${budget}.')发布于 2022-03-31 13:39:02
如果我没听错的话,这里有两件事是不对的:
我猜你需要这样的代码:
if budget > 0
cut+= 0.20*MIN(Budget, 500)
if budget > 500
cut+= 0.10*MIN(Budget-500, 9500) // We already applied the cut to the first 500
if budget > 10000
cut+= 0.05*(Budget-10000) // we already applied a cut to the first 10000所以:
https://stackoverflow.com/questions/71687520
复制相似问题