0

Please can someone help me with a code for this?

write a code that takes the sales made at the end of the month of different sales representatives as a list at a paper selling firm e.g dunder mifflin(assume all prices given are in dollars): #if their sales tally at the end of the month is more that 1500 give them a 10% commision, #if it's more than 2000 given them a 15% commision, #and if it's more than 2500 given them a 20% commission #if it''s between 1000 and 1500 no commission for them but they get to keep their jobs, #but if their sales tally is less than 1000 they get fired!

6th Sep 2022, 2:17 AM
Ebube Okpala
Ebube Okpala - avatar
6 Answers
+ 4
morl , it is not considered as a good idea to post a ready-made code since the asker has not posted what he has tried so far. this behaviour does not give the asker the chance to solve the task by himself. giving hints and tips would be the better way of keeping sololearn a an educational platform.
6th Sep 2022, 11:06 AM
Lothar
Lothar - avatar
+ 2
depending on if you are taking multiple arguments, you could wrap it in a for statement. Then for each case use an if/elif/else statement based on the sales brackets where you can calculate the commission.
6th Sep 2022, 2:39 AM
morl
morl - avatar
+ 1
mapping and filtering will return a list. The syntax is more complex so if you take a peek here. https://cs.stanford.edu/people/nick/py/JUMP_LINK__&&__python__&&__JUMP_LINK-map-lambda.html list(map(lambda n: n * -1, nums)) n being the output for each element, followed by what you would need to be a large amount of logic with what you would need to do. if your logic is more than 80 characters you can also use defined functions for mapping. And it will return a list. - I'd love to see a great mathematician turn this into a lambda but that's beyond my pay grade. It's best to keep python clear in what you are doing anyways. l = [0,700,1400,2100,2600] def commissions(n): if n>2500: return(n * 0.2) elif n>2000 and n<=2500: return(n * 0.15) elif n>1500 and n<=2000: return(n * 0.1) elif n>=1000 and n<=1500: return(n * 0.0) else: return("fired") print(list(map(commissions,l)))
6th Sep 2022, 4:07 AM
morl
morl - avatar
0
morl Would it work if I were to use the map or filter function?
6th Sep 2022, 3:03 AM
Ebube Okpala
Ebube Okpala - avatar
0
that would be the hard way to do it, mapping could change the values base on the true or false conditions (you'd have to perfect the logic and there is more room for error with map and filter).
6th Sep 2022, 3:29 AM
morl
morl - avatar
0
Okay, but is there anyway the output can be in the form of a list
6th Sep 2022, 3:44 AM
Ebube Okpala
Ebube Okpala - avatar