+ 2

Hii I'm trying to solve the paint costs challenge. Can someone pls tell me how to round to the nearest whole number?

colors=int(input()) total=40+colors*5 print(total+0.1*total)

7th May 2023, 1:36 PM
Rainnn
Rainnn - avatar
7 Answers
+ 3
You can round up a value by using ceil() function of math module. ceil( total ) #import ceil() You can round to some decimal places by round() function. round(total) round down to nearest integer by floor() function. floor( total)
7th May 2023, 2:17 PM
Jayakrishna šŸ‡®šŸ‡³
+ 2
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
7th May 2023, 1:36 PM
Rainnn
Rainnn - avatar
+ 2
Jayakrishna šŸ‡®šŸ‡³ I tried writing print(floor(total+0.1* total)) but it didn't work. What should I do?
7th May 2023, 3:32 PM
Rainnn
Rainnn - avatar
+ 2
Floor() round down to nearest integer like 12.5 to 12, 23.8 to 23 To round up, you need 12.4 to 13, 12.8 to 13.0 so you need to apply ceil() function. Import math module before..
7th May 2023, 3:59 PM
Jayakrishna šŸ‡®šŸ‡³
+ 2
You're welcome..
7th May 2023, 7:45 PM
Jayakrishna šŸ‡®šŸ‡³
+ 1
Ok tysm!!
7th May 2023, 3:28 PM
Rainnn
Rainnn - avatar
7th May 2023, 5:40 PM
Rainnn
Rainnn - avatar