I am trying to calculate total money after deduction of a Fee from Upwork. I found this website that does this but I want to make it using Python. Here is the guidelines from Upwork:
$0-$500 in earnings from a client: 20% service fee applied to earnings.
$500.01-$10,000 in earnings from a client: 10% service fee.
$10,000.01 or more in earnings from a client: 5% service fee.
The code:
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}.')
According to Upwork,
On a $600 project with a new client, your freelancer service fee would be 20% on the first $500 and 10% on the remaining $100. Your earnings after fees would be $490.
I made this calculator but it works only for the first condition $0-$500 in earnings
. If the budget is $600
, I will get $490
but here I am getting $540
. Can someone help me out what went wrong?
--Update--
I also tried this but of no use:
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}.')
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}.')