+ 1

Kaleidoscopes

I dont know how to solve the kaleidoscope code coach, it keeps outputing the wrong number by 0.10 This is my code: amount=int(input()) price=5 total=price*amount tax=(price/100)*7*amount discount=(total/100)*10 if amount>1:print(total+tax-discount) else:print(total+tax) The result should be 14.45 if the input is 3 but I keep getting 14.55. What do I do?

23rd May 2025, 1:22 PM
Lucy
Lucy - avatar
5 Respostas
+ 3
do you know how to write if/else statement is python? if: True else: False I hope this helps
23rd May 2025, 2:08 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
+ 2
Lucy There are several minor issues in your code such as: 1>Apply tax on the discounted price means find discount first then subtract it from the total price and then find the tax on total. 2>round the final value by 2 decimal points like `print(round(discountedPrice+tax,2))` 3>Invalid for the case when input is 1 as there will be no discount when user purchase one kaleidoscope:- print(round(amount*5+amount*5 * (7/100),2))
23rd May 2025, 2:16 PM
Gulshan Mahawar
Gulshan Mahawar - avatar
+ 2
Lucy Also to make your code prettify(in arranged manner) follow what Mihaly Nyilas told.
23rd May 2025, 2:18 PM
Gulshan Mahawar
Gulshan Mahawar - avatar
+ 2
@Gulshan Mahawar giving a working code without explaining it.... is it okay?
23rd May 2025, 7:38 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
0
I checked your code with a proper syntax. the problem is with the `tax`. you have to calculate it separately
23rd May 2025, 2:14 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
OSZAR »