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