+ 1

Where did I Go Wrong?

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

19th Dec 2024, 4:13 AM
HASAN IMTIAZ
HASAN IMTIAZ - avatar
6 Respostas
+ 2
Check the rounding requirement. The code needs to round up. The round() function that is used here rounds either up or down, depending on the value. There is a more appropriate function for rounding up.
19th Dec 2024, 5:52 AM
Brian
Brian - avatar
+ 1
houses = int(input()) #your code goes here x = round((2/houses)*100) print(x)
19th Dec 2024, 4:14 AM
HASAN IMTIAZ
HASAN IMTIAZ - avatar
0
Brian I don't know I was Doing Code Coach.. and I Come up With This Solution.....but idk Why. Only 2 output are Correct but Other were not
19th Dec 2024, 6:40 AM
HASAN IMTIAZ
HASAN IMTIAZ - avatar
0
You can See it In My Profile....Code Coach Name candy
19th Dec 2024, 6:42 AM
HASAN IMTIAZ
HASAN IMTIAZ - avatar
0
Brian is telling you to look for other functions instead of round() because it also rounds down - which is not what you want.
19th Dec 2024, 6:51 AM
Ausgrindtube
Ausgrindtube - avatar
0
To determine the percentage chance that a random item from your trick-or-treat bag is a dollar bill, you need to know the total number of houses you visited. If you visited 4 houses, with 1 giving toothbrushes and 2 giving dollar bills, the calculation would be: (2/4) * 100 = 50%. Therefore, there's a 50% chance that a random item from your bag will be a dollar bill.
19th Dec 2024, 9:17 AM
Norma Shah