0

Kaleidoscope problem(with python)

1.customer orders the kaleidoscope(5.00 per one). 2.if the customer buys more than one, they get a 10% discount on every product. 3. tax 7% needs to be applied. 4. The discount comes first, and then taxes a = float(input()) #used float to calculate float if a > 1: a -= a*0.1 #discount ord_num += ord_num*0.07 #tax print("%.2f"%(ord_num*5))#iamidiot this is on the codecoach as an “easy” level this code can get past test 4, but fails at 5. why?

28th Sep 2023, 12:02 PM
Tae Jun Kim
4 Answers
+ 4
Tae Jun Kim , > the logic of the code is difficult to read and to understand. it also can not pass the test cases. var `a` takes an input from user which is the *number of items*. later on in the `if conditional` it is discounted. we have to discount the calculated price, but not the number of items. try to follow this: > take an integer number as input. > if number of items is 1: > apply the tax to the item price like: 5 * 1.07 > if number of items is greater than 1: > multiply the number of items by 5, and apply the discount and tax like: number_of_items * 5 * 0.9 * 1.07 > output the result to 2 decimal places.
28th Sep 2023, 7:31 PM
Lothar
Lothar - avatar
+ 5
'a' is number of orders so it is number type input not float type amount would be a * 5.0 #calculate amount amount = a * 5.0 if a > 1: #subtract discount amount = amount - amount * 0.1 # add tax amount = amount + 0.07 * amount
28th Sep 2023, 12:40 PM
A͢J
A͢J - avatar
+ 2
Ok. Thank you for your help
28th Sep 2023, 12:41 PM
Tae Jun Kim
+ 2
thank you. Both explains great. I solved the problem.
29th Sep 2023, 2:59 AM
Tae Jun Kim