+ 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)

24th Feb 2020, 4:26 PM
Marvellous Abia
Marvellous Abia - avatar
12 odpowiedzi
+ 2
Marvellous Abia Why you use int when calculating tax
24th Feb 2020, 5:29 PM
Mihai Apostol
Mihai Apostol - avatar
+ 3
The instructions ask you to ROUND UP to the nearest whole number. Try ceil()
24th Feb 2020, 4:38 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
24th Feb 2020, 4:52 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Mihai Apostol I can't believe that's what's been holding it. Thanks. It worked.
24th Feb 2020, 5:34 PM
Marvellous Abia
Marvellous Abia - avatar
+ 1
Please use search bar. Many had problems with this Code Coach Challenge. Do some research.
24th Feb 2020, 4:29 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Marvellous Abia from math import ceil or import math and then to call it math.ceil()
24th Feb 2020, 4:51 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Marvellous Abia You're welcome. And belive that, because when using int you were removing the decimal part of that result.
24th Feb 2020, 5:36 PM
Mihai Apostol
Mihai Apostol - avatar
+ 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)
11th Jul 2020, 9:46 PM
Timi Toba
Timi Toba - avatar
0
ceil() is not a default function. I think it has to be defined first.
24th Feb 2020, 4:49 PM
Marvellous Abia
Marvellous Abia - avatar
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.
24th Feb 2020, 5:25 PM
Marvellous Abia
Marvellous Abia - avatar
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)
25th Feb 2020, 8:15 PM
Yashshree Patil
Yashshree Patil - avatar
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)
25th Feb 2020, 8:23 PM
Yashshree Patil
Yashshree Patil - avatar