issue with rounding problem 6

Back to General discussions forum

neelsaxena42     2025-06-07 15:36:20

i tried too many times but every time there is slight error in system output to my output.. even i took help of AI but then also there is same problem

neelsaxena42     2025-06-07 15:39:33
def rounding(a,b):
    return round(a/b)
c=int(input())
for i in range(c):
    a,b=map(int,(input().split()))
    print(rounding(a,b),end=" ") 
gardengnome     2025-06-07 17:00:02
User avatar

Hi, the problem asks to round "away from zero". You try to use the built-in Python function round to do this, but this function behaves differently. This means you need to do a little bit of case work.

neelsaxena42     2025-06-07 20:06:44

i used every method but problem persist. i used round function also but then also 1-2 test case is failed

LuisAguiar     2025-06-12 00:12:21
User avatar

I would recommend you to create your own rounding (also, AI gets messy with this cases analysis idk why exactly but it's not the best tool in that problem)

If the decimal part is in the range .0 to .4 then use floor function, else, do ceiling. I hope that is clear enough for you to fix the program.

Rodion (admin)     2025-06-14 18:03:30
User avatar

AI gets messy with this cases analysis idk why exactly but it's not the best tool in that problem

amusing observation, thanks for sharing this! :)

neelsaxena42     2025-06-16 14:25:44

Thanks Everyone! i am able to to solve rounding problem after many try ...finally!!

Please login and solve 5 problems to be able to post at forum