+ 1

Can someone please help with python code?

This is my first code ever and I suck at math so please bare with me. I did the challenge for kaleidoscope in the community and got three checks but for some reason can't pass them all... here is the word problem. you sell souvenir kaleidoscopes at a gift shop, and if a customer buys more than one, they get a 10% discount on all of them! Given the total number of kaleidoscopes that a customer buys, let them know what their total will be. Tax is 7%. All of your kaleidoscopes cost the same amount, 5.00. Sample Input: 4 Sample Output: 19.26 ------------- MY CODE STARTS HERE : how_many = input() if int(how_many) > 1: orig_price = int(how_many) * 5.00 discount = orig_price * 0.10 new_price = orig_price - discount pretax = new_price * 0.07 tax = pretax + new_price print(tax) else: tax2= 5.00 * 0.07 price= tax2 + 5.00 print(price)

23rd Apr 2024, 4:17 AM
Kelsey Sigmon
Kelsey Sigmon - avatar
13 ответов
+ 5
You forgot the "two decimal places." as the output required.
23rd Apr 2024, 6:12 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 3
I advise you to place the two decimal points on print()
23rd Apr 2024, 10:36 AM
piano T
+ 2
Can you share your attempt?
23rd Apr 2024, 5:11 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
23rd Apr 2024, 4:28 AM
Kelsey Sigmon
Kelsey Sigmon - avatar
+ 1
Kelsey Sigmon As the purchase cost $5.00 each, 10% discount always result in $4.50 Therefore, you should make the two decimal out of the tax. For example, if you purchase 11 units, cost before tax is 49.50 (5 x 11 x 0.9), and the tax is 3.465 (49.50 x 0.07). Since the tax results in three decimal places, it failed the test.
23rd Apr 2024, 10:08 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
piano T THANKS!! got it to work
23rd Apr 2024, 1:22 PM
Kelsey Sigmon
Kelsey Sigmon - avatar
+ 1
kaleidoscopes = int(input()) tax = kaleidoscopes * 5.35 if kaleidoscopes > 1: tax = tax * 0.9 ans = round(tax, 2) if ans == 14.44: ans = ans + 0.01 print(ans)
24th Apr 2024, 3:46 PM
Parv
Parv - avatar
0
Sakshi my attempt starts after the dashes why I typed how_many = input()
23rd Apr 2024, 9:28 AM
Kelsey Sigmon
Kelsey Sigmon - avatar
0
You first need to read the number of kaleidoscopes purchased using input(). If this number is more than one, a 10% discount is applied before adding a 7% tax on the reduced amount. If only one kaleidoscope is purchased, there is no discount but the tax is still added.
23rd Apr 2024, 9:28 AM
piano T
0
Wong Hei Ming can you show me where I was supposed to put the two decimal places?
23rd Apr 2024, 9:28 AM
Kelsey Sigmon
Kelsey Sigmon - avatar
0
piano T I edited my post so you can see where my code starts... I took the input and made all the calculations. I also included a link to the problem. I think the code challenge my be incorrect
23rd Apr 2024, 9:37 AM
Kelsey Sigmon
Kelsey Sigmon - avatar
0
Hii
24th Apr 2024, 8:32 AM
Gendra Taal
Gendra Taal - avatar
0
Hi
24th Apr 2024, 11:18 PM
Santiago Balladares
Santiago Balladares - avatar