Why am i getting test case #4 wrong? Code coach. Can someone please simplify this code as well? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why am i getting test case #4 wrong? Code coach. Can someone please simplify this code as well?

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

27th Dec 2019, 4:34 PM
Quinn Joseph
Quinn Joseph - avatar
2 Answers
+ 3
The fourth test case failed in the code coach challenge. I've written this code in multiple different ways and it still doesn't work on that fourth test case.
27th Dec 2019, 10:14 PM
Quinn Joseph
Quinn Joseph - avatar
+ 2
The code isn't working because the instructions specify to "round up" and "round(" in python rounds half away from zero, e.g. 14.4 would round to 14 while the instructions indicate you should round to 15. I had the the same problem, and it made me read other ones atleast a little more carefully. As far as simplifying: I think you are using int( and round( more than necessary, e.g. int(round(t+p)) doesn't need round( because t and p are already integer values. For the same reason you don't need int( there. Also, you wouldn't need int( after using round( anyway, because that method returns an integer when you don't specify ndigits. You also don't really need so many variables unless it just makes it easier for you to follow. 40 and 5 are constants here and you could just calculate all in one go, i.e., 1.1(40+5*x) will take care of the calculation for you, though not the rounding.
28th Dec 2019, 12:12 PM
Mark
Mark - avatar