A couple of weeks ago I had to do a coding challenge for a job interview. I did the challenge using Python, the code was working and I got the job. But I would like to know how (if possible) I can improve/refactor the code I've written. The reviewer told my future employer there were too many if statements and that I could have written better code. I guess this is an example of too many if statements:
def get_row_tax_percentage(product_name: str): exempt = is_exempt(product_name) imported = is_imported(product_name) if exempt and imported: return Decimal(".05") elif exempt and not imported: return Decimal("0") elif imported: return Decimal(".15") else: return Decimal(".1")
Link to the task description: https://github.com/xpeppers/sales-taxes-problem
Link to my solution: https://github.com/soulpaul/sales-taxes-solution
I think this could be a chance to learn something new. I don't need you guys to write code for me, but please point me to the right direction. Thanks to anyone who is going to spend some time on this.