Please help me debug | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please help me debug

Question 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 My code : c=int(input()) bill=(c*5)+40 tax=bill*(10/100) t=bill+tax print(int(t)) Can please help me debug

22nd Nov 2023, 5:23 AM
Sanjana
Sanjana - avatar
5 Answers
+ 4
There is something written in the Output Format: "...rounded up to the nearest whole number." You will need a built-in module to help you.
22nd Nov 2023, 6:48 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 2
Wong Hei Ming thank you
22nd Nov 2023, 10:50 AM
Sanjana
Sanjana - avatar
+ 2
Rain thanks:)
25th Nov 2023, 12:45 PM
Sanjana
Sanjana - avatar
+ 1
int() rounds always down. Using the built-in round() function will round to the nearest integer if only the number is given. (To force rounding up you have to add 0,5 to the number.)
22nd Nov 2023, 9:16 PM
Viktor Kovács
Viktor Kovács - avatar
+ 1
In the math module, ceil() rounds up. https://docs.python.org/3/library/math.html?highlight=ceil#math.ceil By the way, this, tax=bill*(10/100) can be simplified to this, tax=bill/10 or this. tax=bill*0.1
24th Nov 2023, 9:45 AM
Rain
Rain - avatar