0

When this code won't be executed (just 3 cases from 5 were correct )

https://code.sololearn.com/cZ5PfK5PshZw/?ref=app

8th Apr 2023, 1:15 AM
Sarah
5 Antworten
+ 6
Sarah , the rounding is required because what we are rounding is the *final result*. this is a float type, because we are using a division for calculating the tax: > if we use 5 colors the total cost will be => 71.5 without rounding > we can also get a result, (dependent on the way how we calculate e.g. tax) like this: using 14 colors => 121.00000000000001 without rounding. using 15 colors => 126.49999999999999 without rounding. so rounding makes it easy to manage the test cases by rounding up the results.
9th Apr 2023, 3:51 PM
Lothar
Lothar - avatar
+ 5
Sarah , the task description says: ... Output Format A number that represents the cost of your purchase rounded up to the nearest whole number. ... ^^^^^^^^^^^^^
8th Apr 2023, 8:31 PM
Lothar
Lothar - avatar
+ 4
Use ceil or round function
8th Apr 2023, 1:26 AM
Hasnain [ACTIVE CHALLENGER]
Hasnain [ACTIVE CHALLENGER] - avatar
+ 1
Lothar I got it, thanks a lot
9th Apr 2023, 10:26 PM
Sarah
0
Lothar Ive solved it thank u But wouldn't the number of colors be integer ,so why will we need it?
9th Apr 2023, 2:59 PM
Sarah