+ 1

A confusion with the Halloween Candy problem from Code Coach

Can anybody tell me why this code is not working?below mentioned code is not working for test result 3,4&5. p = (2/houses)*100 b = p%1 if b<=0.5: p = p-b else: p = p-b+1 print(int(p))

5th Jun 2020, 12:37 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
11 odpowiedzi
+ 2
Rithea Sreng Thanks a lot lot lot. It worked <3
5th Jun 2020, 1:56 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
+ 2
oh! It is easy. I thought it would be complex. Thanks for clearing it up in seconds :D
5th Jun 2020, 2:07 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
+ 1
Rithea Sreng print(3.5%1) gives a output 0.5. So it won't be zero.
5th Jun 2020, 1:05 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
+ 1
But I have b>0
5th Jun 2020, 1:14 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
+ 1
Is there any way to know what was in test result 3,4&5?
5th Jun 2020, 1:57 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
+ 1
I have seen this solution in discussions. Now I have to learn how .ceil() works. Thanks ^_^
5th Jun 2020, 2:05 PM
Mir Abir Hossain
Mir Abir Hossain - avatar