+ 3

What is wrong with my code?

In results, tests 2 3 and 4 are correct but tests 1 and 5 are incorrect. I’m getting the comment to correct the bugs. My code: paint = int(input()) import math print(math.ceil(((paint * 5) + 40) * 1.1)) Please help me!

19th Sep 2021, 1:59 AM
Riyana Gibson
Riyana Gibson - avatar
13 Respostas
+ 4
Did you try to use round() ? Sometimes, math.ceil will round up to the actual answer +1 since it's multiplied by a float(1.1).
19th Sep 2021, 2:45 AM
Python Learner
Python Learner - avatar
+ 4
Thank you everyone! I used round() instead of math.ceil() and all tests results were correct. Appreciate the help!
19th Sep 2021, 3:15 AM
Riyana Gibson
Riyana Gibson - avatar
+ 1
I’m so sorry; please see below! You are getting ready to paint a piece of art. The canvas and brushes that you want to use will cost 40.00. Each color of paint that you buy is an additional 5.00. Determine how much money you will need based on the number of colors that you want to buy if tax at this store is 10%. Task Given the total number of colors of paint that you need, calculate and output the total cost of your project rounded up to the nearest whole number.
19th Sep 2021, 2:32 AM
Riyana Gibson
Riyana Gibson - avatar
+ 1
Riyana Gibson ah, I think it's a misunderstanding about the ceil function?? Maybe look into that, I found a solution by replacing math.ceil with round...
19th Sep 2021, 2:44 AM
Chloe
Chloe - avatar
+ 1
JUMP_LINK__&&__Python__&&__JUMP_LINK Learner thanks for the further explanation with math.ceil() Still learning the basics.
19th Sep 2021, 3:16 AM
Riyana Gibson
Riyana Gibson - avatar
0
Can you include the description of the problem as well? It would be really helpful 😊
19th Sep 2021, 2:21 AM
Chloe
Chloe - avatar
0
Hi Riyana! Can you give some informations about your challenge or its name? For now, we can say that math.ceil() is used to round up to the nearest integer while round() is for usual rounding values.
19th Sep 2021, 2:25 AM
Python Learner
Python Learner - avatar
0
➔Chloe[she/her] when I multiply by 0.1, all test results are incorrect.
19th Sep 2021, 2:37 AM
Riyana Gibson
Riyana Gibson - avatar
0
Riyana Gibson oops..? Let me look at it again.
19th Sep 2021, 2:38 AM
Chloe
Chloe - avatar
0
Riyana Gibson Since you're using Math.ceil() to round the tax up, if you use 1.1 instead of 0.1 it will potentially round up a greater amount making the answer incorrect. Instead use 0.1 and add the supplies amount to the tax. This should resolve the issue. Example; supplies = (paint * 5) + 40 tax = supplies * 0.1 total_cost = supplies + tax You can do it all in 1 line, but I wrote it out this way for clarification.
19th Sep 2021, 2:49 AM
ChaoticDawg
ChaoticDawg - avatar
0
Try using round instead of ceil. The task says you should round up, so ceil should be correct, but that didn't work for me. My code was accepted when I used round instead.
19th Sep 2021, 3:08 AM
Simon Sauter
Simon Sauter - avatar
- 2
Riyana Gibson multiplying by 1.1 returns 110%, if I've understood correctly it should be multiplied by 0.1.
19th Sep 2021, 2:34 AM
Chloe
Chloe - avatar
- 4
Hello
19th Sep 2021, 9:10 PM
Makseem
Makseem - avatar