I'm doing an exercise:
A factory has 10 representatives. Each receives a commission calculated from the number of items in an order, according to the following criteria: - for up to 19 items sold, the commission is 10% of the total value of the order; - for orders of 20 and 49 items, the commission is 15% of the total value of the order; - for orders from 50 to 74 items, the commission is 20% of the total value of the order; and - for orders equal or higher, at 75 items the commission is 25%.
Make a program that reads the order quantity of each representative and prints the commission percentage of each one.
I thought of creating a variable for each entry, ie a variable for each delegate and at the end to generate the commissions by putting several if elif and else. My question is to leave this code leaner without having to create the 10 variables?
More or less I made this piece of code that gives me the 10 entries. But from now on I curled up in time to create the conditionals to generate the value of each commission of each representative.
My code outline, with the entries:
print ("\n--------------------------------------------------------")
print ("\n--------------------------------------------------------")
def exercicio():
itens = []
item = 0
while item == 0:
item = float(input("\nQuantidade de Itens do 1º Representante: "))
if item < 0:
print("\nAs Quantidades não podem ser menores que Zero.")
itens.append(item)
for i in range(9):
item = float(input("\nQuantidade de Itens do %dº Representante: " % (i+2)))
itens.append(item)
print("\n",item)
print ("\n",itens)
exercicio()
print ("\n--------------------------------------------------------")
print ("\n--------------------------------------------------------")