0
What is different??
For the problem of paint cost in code coach i tried this 2 codes:- 1st n = int(input()) total = n*5 + 40 tax = total/10 print(int(round(tax+total,0))) 2nd n = int(input()) total = n*5 + 40 tax = round(total/10,0) print(int(tax+total)) If i use the 1st code the 3rd test case fails and if i use 2nd code 4th test case fails. Can some body help me understand what is wrong in both of these codes.
3 Respostas
+ 8
Akash Sil
This thread has everything contains.
https://www.sololearn.com/discuss/2104980/?ref=app
+ 6
The Task description says that you should "round up" the result. In the code "round"() is used, but this is rounding to the next possible integer. This can be a rounding up, or a rounding down. So you have to use the "ceil()" function, which is always rounding up to the next integer. Therefore you have to import math like:
from math import ceil
then use ceil(...) instead of round()
0
I solved the problem by the following method👇
n = int(input())
total = n*5 + 40
tax = total/10
tx =str(tax)
if int(tx[-1])>=5:
tax = int(tax)+1
else:
tax = int(tax)
print(tax+total)