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!
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).
Thank you everyone! I used round() instead of math.ceil() and all tests results were correct. Appreciate the help!
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.
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...
JUMP_LINK__&&__Python__&&__JUMP_LINK Learner thanks for the further explanation with math.ceil() Still learning the basics.
Can you include the description of the problem as well? It would be really helpful 😊
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.
➵Chloe[she/her] when I multiply by 0.1, all test results are incorrect.
Riyana Gibson oops..? Let me look at it again.
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.
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.
Riyana Gibson multiplying by 1.1 returns 110%, if I've understood correctly it should be multiplied by 0.1.