+ 1

Code coach round off giving problem😢

Help

2nd Feb 2020, 5:41 AM
Huzaifa Khilawala
Huzaifa Khilawala - avatar
8 Antworten
+ 14
Huzaifa Red Headphone generally on using Ceil from math can be helpful in rounding thing other than round() function which problem you are facing rounding problem include that too
2nd Feb 2020, 5:54 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 10
Huzaifa Red Headphone without seeing the code we can say on which scenarios the rounding in not working for which problem. So link the code in the post so we can review it
2nd Feb 2020, 2:00 PM
GAWEN STEASY
GAWEN STEASY - avatar
0
what are you rounding to? from two decimal places to the nearest whole?
2nd Feb 2020, 7:39 AM
SQrL
SQrL - avatar
0
SQrL whole no. Neither round () nor // work right 😑
2nd Feb 2020, 10:39 AM
Huzaifa Khilawala
Huzaifa Khilawala - avatar
0
ok, if you multiply to get into whole numbers, maybe even before division, rounding can be more accurate. i will try to find you something specific to explain it better
2nd Feb 2020, 1:55 PM
SQrL
SQrL - avatar
0
subt=(sub1+sub2)*110 if(subt%100==0): print(int(subt/100)) else: print(int(subt/100)+1)
2nd Feb 2020, 10:49 PM
SQrL
SQrL - avatar
0
In the code example above i multiplied by 110, which is a percentage. By processing as ints as long as possible I could use the modulus operator to handle my own rounding and always round up to the next whole number, which is differennt tgan what round would do. If you want classic rounding change tge if to compare to 50
2nd Feb 2020, 10:52 PM
SQrL
SQrL - avatar
0
SQrL ceil function worked out thanks 😄
3rd Feb 2020, 2:49 AM
Huzaifa Khilawala
Huzaifa Khilawala - avatar