Halloween candy | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Halloween candy

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 My answer: houses = int(input()) pc = (2*100)/houses pcr = round(pc) print(pcr) Why it dont work? 😭

2nd Nov 2023, 8:00 PM
Axel00x
Axel00x - avatar
4 Answers
+ 7
Have a close look at the output format: You are supposed to round ***up*** to the nearest whole number.
2nd Nov 2023, 8:09 PM
Lisa
Lisa - avatar
+ 3
To roundup a number, you need the math library. Take some time to research how to import library and how to use them.
3rd Nov 2023, 1:23 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 2
The text: "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."
2nd Nov 2023, 8:02 PM
Axel00x
Axel00x - avatar
+ 1
Needed to roundup , if you're using c++ use <cmath> library
3rd Nov 2023, 12:28 PM
Alhaaz
Alhaaz - avatar