+ 2
Halloween candy
Hi, I'm stucked and I I can't figure out the solution. Can someone help me (I'm not interested in the solution, but what I don't notice)? Thank you very much The code: houses = int(input()) p = ((2 / houses)*100) rounded = round(p) print(rounded)
9 Réponses
+ 2
There are 3 functions to round a number.
Your number to round:: 37.37
Round() = 37
Ceil() = 38
Floor() = 37
In case the number were 37.67 for example Round would return 38. Since 37.67 it's closer to 38.
37.37 for example it's closer to 37.
37.49 would return 37.
and finally 37.51 would return 38.
+ 4
Flóra-Szekeres Barbara ,
# I thought you didn't want coding help.
# Since your search is broken,
# ceil is short for ceiling.
# For example,
from math import ceil
print(ceil(100/3)) # 34
+ 3
You don't want the solution. Cool.
What you missed is that the description says you're supposed to round up.
+ 1
But there is a round() function. Should it be used, or is there another method?
+ 1
Hmmm, thanks. But still you told But still, you told me the solution 😔🙂🙈
Thanks for your help, have a nice day
+ 1
I didn't even want coding help, I learn from mistakes.
I didn't know with this ceil, I'm still learning the basics. But now I'm learning
+ 1
If you feel bad about the spoiler, treat is as "you need a library call 'math'".
As you advance in the code coach, you will need another library to help you.
+ 1
I use ceil. But first we need to import from math library.
from math import ceil
print(ceil(p))
+ 1
Thx, this is one of the most useful comment. 💖