+ 1

Stuck on paint costs

Not sure whats wrong with my code, outputs a number in the 10000s paint = int(input() * 5) total = paint + 40 tax = int(total / 10) trueTotal = int(tax + total) print(trueTotal)

29th Jun 2022, 6:29 PM
Datboi
Datboi - avatar
11 Answers
+ 2
int(input() * 5) converts to integer a 5 times concatenation of the input string. So, if you enter "1", paint will become 11111.
30th Jun 2022, 12:13 AM
Emerson Prado
Emerson Prado - avatar
+ 1
Is it in python that you need // to divide properly?
29th Jun 2022, 7:33 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Ausgrindtube It depends on what "properly" means in each context. // is "floor division".
30th Jun 2022, 12:17 AM
Emerson Prado
Emerson Prado - avatar
+ 1
[user id=1815355]Emerson Prado[/user] , I fixed that part with int(input()) * 5, which gave me correct for most test cases, but it still fails on 3 & 4
30th Jun 2022, 6:44 AM
Datboi
Datboi - avatar
+ 1
Datboi Let us see your actual code, instead of a copy and changes scattered among amswers. Pls edit your question description and include a link to your code in Code Playground - use "+" button. This way, everyone can debug, it's always updated, and easy to find.
30th Jun 2022, 9:42 AM
Emerson Prado
Emerson Prado - avatar
+ 1
Datboi Get used to the idea of linking the code in the question description, instead of in answers. Some more answers and this will get lost among the others. That said, two questions: 1. What is the task? 2. Why do you convert to int several times?
1st Jul 2022, 1:14 AM
Emerson Prado
Emerson Prado - avatar
+ 1
Datboi OK. Try removing all integer conversions and roundings, and see the results. We'll be in a clean state, at least.
1st Jul 2022, 2:30 PM
Emerson Prado
Emerson Prado - avatar
+ 1
[user id=1815355]Emerson Prado[/user] , Thanks for the help, I managed to solve it by using the math.ceil function Import math math.ceil()
1st Jul 2022, 5:19 PM
Datboi
Datboi - avatar
0
[user id=23234819]Ausgrindtube[/user] , making it total // 10 doesn’t help either
29th Jun 2022, 8:01 PM
Datboi
Datboi - avatar
0
[user id=1815355]Emerson Prado[/user] https://code.sololearn.com/cwQRW4aWD7Zf/?ref=app
30th Jun 2022, 3:10 PM
Datboi
Datboi - avatar
0
[user id=1815355]Emerson Prado[/user], the task is to take the number of paint colours, multiply by 5 for price, add 40 for the canvas and add 10% of paint and canvas for the tax. And the reason I converted to int multiple times was because I was trying to fix the problem I had earlier
1st Jul 2022, 6:27 AM
Datboi
Datboi - avatar