+ 1

Paint Costs Code Coach - Python Help!

I've attempted the 'Paint costs' code coach, and have run into a wall. My code works for three of the five test cases, but the test cases which it doesn't work for are locked, so I can't see why they're not working. Here is the task, plus my code. Any help would be greatly appreciated! --------- You are getting ready to paint a piece of art. The canvas and brushes you want to use will cost 40.00. Each colour of paint that you buy is an additional 5.00. Determine how much money you will need based on the number of colours that you want to buy if tax at this store is 10%. Task Given the total number of colours of paint that you need, calculate and output the total cost of your project rounded up to the nearest whole number. Input format An integer that represents the number of colours that you want to purchase for your project. Output format A number that represents the cost of your purchase rounded up to the nearest whole number. ---------- My code: canvas_brushes = 40.00 paint = 5.00 paint_number = int(input()) paint_total = paint_number * paint total = canvas_brushes + paint_total tax_total = 1.1 * total print(int(tax_total))

1st Jul 2022, 11:53 AM
Steph
5 Answers
+ 1
totalPaint = float(input()) canvasBrush = 40 paint = 5 totalSumPaint = paint * totalPaint totalCost = totalSumPaint + canvasBrush tax = totalCost / 10 totalProjectCost = tax + totalCost print(round(totalProjectCost))
1st Jul 2022, 12:06 PM
JaScript
JaScript - avatar
+ 2
base = 40 color = int(input()) colors = color * 5 tax = 1.1 res = (base + colors) * tax print(round(res)) You need the round, int(res) cuts the result. If you have 17.9 int(17.9) = 17 round(17.9) = 18
1st Jul 2022, 1:07 PM
Aurélien Robert
Aurélien Robert - avatar
+ 1
JaScript Thanks! Would you mind explaining the round() function, as I don't remember that being covered in the beginner's course? Also, is there a specific reason why multiplying by 1.1 didn't work to increase the total by 10%?
1st Jul 2022, 12:27 PM
Steph
+ 1
Aurélien Robert Amazing, thanks for the explanation!
1st Jul 2022, 1:09 PM
Steph
+ 1
The clarification has already been made. Steph I would like to add that it is highly recommended first to test the code in Sololearn playground with a few print statements between and see what happens there and think out about why. And then if all else fails, you can of course ask here. This way you can learn to solve tasks.
1st Jul 2022, 2:46 PM
JaScript
JaScript - avatar