+ 1
Coach Code ( Paint Cost).
I don't know why test 3 and 4 are failing in my code. Here it is : n = int(input()) cost =40.0 canvas = n*5 tax = int((cost+canvas)*0.1) total = round(cost + canvas + tax) print(total)
12 Answers
+ 2
Marvellous Abia
Why you use int when calculating tax
+ 3
The instructions ask you to ROUND UP to the nearest whole number.
Try ceil()
+ 3
Mihai Apostol thanks
+ 2
Mihai Apostol I can't believe that's what's been holding it. Thanks. It worked.
+ 1
Please use search bar. Many had problems with this Code Coach Challenge.
Do some research.
+ 1
Marvellous Abia
from math import ceil
or
import math
and then to call it
math.ceil()
+ 1
Marvellous Abia You're welcome.
And belive that, because when using int you were removing the decimal part of that result.
+ 1
well this is what i use and i guarantee you that it works perfectly
def cost(color):
brush = 40
paint = color*5
tax = (brush+paint)*0.1
if (tax%5!=0):
tax+=0.5
total = int(brush+paint+tax)
return(total)
n = cost(int(input()))
print (n)
0
ceil() is not a default function. I think it has to be defined first.
0
from math import ceil
n = int(input()) I just
cost =40.0
canvas = n*5
tax = int((cost+canvas)*0.1)
total = ceil(cost + canvas + tax)
print(total)
Is still giving the same issue. test 1,2, and 5 passed but 3 and 4 didn't. Those 2 guys didn't read, I guess that's why they failed.
0
do this it clears all the test cases, your solution dont not work cuz its not rounding up the number properly.
def cost(color):
brush = 40
paint = color*5
tax = (brush+paint)*0.1
if (tax%5!=0):
tax+=0.5
total = int(brush+paint+tax)
return(total)
n = cost(int(input()))
print (n)
0
to use ceil function import math and use ceil function as math.ceil
import math
def cost(color):
brush = 40
paint = color*5
tax = math.ceil((brush+paint)*0.1)
total = brush+paint+tax
return(total)
n = cost(int(input()))
print(n)