+ 1

Help needed with Halloween Candy ,only test cases 1 and 2 r correct.

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. Sample Input 4 Sample Output 50 This is my code __________________________________________ houses = int(input()) #your code goes here dollar_bill = 2/houses chance_of_dollar_bill =dollar_bill *100 print(round(chance_of_dollar_bill) )

19th Jan 2023, 9:08 AM
Ochola Mark Joshua
Ochola Mark Joshua - avatar
2 odpowiedzi
+ 5
Ready carefully... you should "round UP". One of the solutions would be to use ceil() function instead of round(). Fix line with print function print(math.ceil(...)) Don't forget to import math, in order to use ceil() function.
19th Jan 2023, 9:16 AM
Lofty
Lofty - avatar
+ 1
Thanks it has really solved my problem
19th Jan 2023, 9:33 AM
Ochola Mark Joshua
Ochola Mark Joshua - avatar