1
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 order value; - for applications of 20 and 49 items, the commission is 15% of the total value of the application; - for applications of 50 to 74 items, the fee is 20% of the total value of the application; and - for applications of 75 items or more the commission shall be 25%.
Make a program that reads the number of order items of each representative and prints the commission percentage of each.
I thought of creating a variable for each entry, ie a variable for each representative and at the end to generate the commissions by placing several if Elif and Else. My question is how to get this code thinner without me having to create the 10 variables?
I sort of made this piece of code that gives me the 10 entries. But from now on, I’ve tangled up to create the conditionals to generate the value of each commission from each representative.
My code sketch, 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--------------------------------------------------------")
Gosh. Thank you very much.
– Rodrigo Rodrigo