0

Why my code doesn't meet all the testcases ??

Here is the problem: 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. Input Format An integer that represents the number of colors 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. Sample Input 10 Sample Output 99 Here is my code: canva_brush = 40 color_num = int(input()) color_price = color_num * 5 first_total = canva_brush + color_price total = int(first_total + (first_total *(10/100))) print(round(total)) There are two test cases that make my code fail and I don't know why??

22nd Dec 2024, 7:04 AM
yasminsherif
3 Respostas
22nd Dec 2024, 7:13 AM
Bob_Li
Bob_Li - avatar
+ 1
Unfortunately also math.ceil gave me an error😭
22nd Dec 2024, 1:57 PM
yasminsherif
+ 1
you're converting to int before applying math.ceil. Don't do that. It truncates the float, so you're giving math.ceil the wrong value. round, math.ceil and math.floor needs float, not int. Sorry, I shoul have noticed that error in your code earlier. https://codedamn.com/news/JUMP_LINK__&&__python__&&__JUMP_LINK/converting-float-to-int-in-python total = first_total + (first_total*(10/100)) print(math.ceil(total))
22nd Dec 2024, 2:15 PM
Bob_Li
Bob_Li - avatar