0
Having trouble with easy kaleidoscope challenge
I'm trying to practice and get better at programming by doing the challenges i need assistance with one of them I feel like I'm close to solving it but can't figure it out Kale is price of kaleidoscope, buy is how many is being bought, tax is the 7% tax, and no_dis is no discount if user buy 4 they get a 10% discount def purchase(kale, buy, tax): no_dis = kale * buy + tax if buy == 4: no_dis / 10 return no_dis x = 5 y = int(input()) t = x * 0.07 tax = t + x result = purchase(x, y, tax) print(result)
1 Respuesta
+ 6
Marshall Lance Freeman ,
here some hints you may follow:
the current code is quite difficult to read and understand, because calculation and logic is split up in main program and a function.
● the basic task is to check if a discount can be given or not.●
> if the number_of_items purchased is greater than 1:
give discount
> else
give NO discount
try to simplify also the calculation itself.
if discount can be given (eg 3 items are purchased):
number_of_items * price_per_item * discount * tax
>>> 3 * 5 * 0.9 * 1.07
if discount can not be given (eg 1 item is purchased):
number_of_items * price_per_item * tax
...
the final output should be rounded to 2 decimal places