0

Have anyone solved this code coach problem? I know its easy but last 3test cases are not getting approved. Kindly check code

You go trick or treating with a friend and all but three of the houses that you visit are giving out candy. One house that you visit is giving out toothbrushes and two houses are giving out dollar bills. Task Given the input of the total number of houses that you visited, what is the percentage chance that one random item pulled from your bag is a dollar bill? Input Format An integer (>=3) representing the total number of houses that you visited. Output Format A percentage value rounded up to the nearest whole number. Code: houses=int(input()) print(round(200/houses))

29th Apr 2021, 1:22 PM
Harshita Sharma
Harshita Sharma - avatar
15 ответов
+ 3
round will round to the nearest whole number. you will need to use math.ceil to always round up to the nearest whole number. example: math.ceil( ( 2 / houses ) * 100 )
29th Apr 2021, 1:35 PM
you are smart. you are brave.
you are smart. you are brave. - avatar
+ 2
No ceil will round off to it's highest near integer. Ex- 5.3, using ceil function u can turn it into 6 but using round of function u can turn it into 5
29th Apr 2021, 2:01 PM
Atul [Inactive]
+ 2
Please kindly post your code here
30th Apr 2021, 5:00 AM
Utsav Singh
Utsav Singh - avatar
1st May 2021, 11:39 AM
Atul [Inactive]
+ 1
Post your code here
29th Apr 2021, 1:35 PM
Atul [Inactive]
+ 1
For me it loads an error saying math function undefined and round still hasn't solved the problem
1st May 2021, 11:10 AM
Iamebson
Iamebson - avatar
+ 1
Ehizzy Ebson first import math module----import math...then apply math.ceil()
1st May 2021, 1:55 PM
Harshita Sharma
Harshita Sharma - avatar
0
Andrew Choi Done, thanks bro
29th Apr 2021, 1:42 PM
Harshita Sharma
Harshita Sharma - avatar
0
But round() and math.ceil() both will round to the nearest whole no. Right?? Then y did we used math.ceil()
29th Apr 2021, 1:45 PM
Harshita Sharma
Harshita Sharma - avatar
0
Atul ohh...ohkkk..thanks
29th Apr 2021, 2:06 PM
Harshita Sharma
Harshita Sharma - avatar
0
Harshita Sharma my pleasure
29th Apr 2021, 5:02 PM
Atul [Inactive]
0
Iutsavsingh it's done..but thanks😊
30th Apr 2021, 8:58 AM
Harshita Sharma
Harshita Sharma - avatar
0
Math.ceil() function is used to round up a number,not round figure the number . suppose,8.1 is a number then 9 is the round up of 8.1
1st May 2021, 7:06 AM
Sreeshmaa
Sreeshmaa - avatar
0
Hi
1st May 2021, 10:30 AM
Badro Badro
Badro Badro - avatar
0
😘
1st May 2021, 10:31 AM
Badro Badro
Badro Badro - avatar