help me out. ...what to do with no output | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

help me out. ...what to do with no output

Halloween Candy +10 XP 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 my code: from math import * houses = int(input()) if houses>=3: a=((2/houses)*100) print(int(round(a)))

16th May 2020, 5:22 AM
Akshat Jain
5 Answers
+ 3
In Output it says the result should be rounded *up* to the next integer. You round mathematically.
16th May 2020, 6:48 AM
Lisa
Lisa - avatar
+ 1
Lisa i am still having a problem houses = int(input()) if houses>=3: a=((2*100)//houses) print(a+1) what should i do to print 20 when ipput is 10... and i am having the output 21
16th May 2020, 10:44 AM
Akshat Jain
+ 1
I think your approach in the description was already fine. The only thing you woul need to change is the round function. Instead of round(), you could use ceil() from the math module.
16th May 2020, 11:38 AM
Lisa
Lisa - avatar
0
oh thnx
16th May 2020, 7:40 AM
Akshat Jain
0
Lisa thnx🤘
16th May 2020, 4:21 PM
Akshat Jain