+ 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)

12th Dec 2023, 8:53 PM
Flóra-Szekeres Barbara
Flóra-Szekeres Barbara - avatar
9 Antworten
+ 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.
14th Dec 2023, 6:43 PM
Juan Pablo Mersuglia
Juan Pablo Mersuglia - avatar
+ 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
13th Dec 2023, 6:12 AM
Rain
Rain - avatar
+ 3
You don't want the solution. Cool. What you missed is that the description says you're supposed to round up.
12th Dec 2023, 10:51 PM
Rain
Rain - avatar
+ 1
But there is a round() function. Should it be used, or is there another method?
13th Dec 2023, 5:42 AM
Flóra-Szekeres Barbara
Flóra-Szekeres Barbara - avatar
+ 1
Hmmm, thanks. But still you told But still, you told me the solution 😔🙂🙈 Thanks for your help, have a nice day
13th Dec 2023, 6:18 AM
Flóra-Szekeres Barbara
Flóra-Szekeres Barbara - avatar
+ 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
13th Dec 2023, 6:22 AM
Flóra-Szekeres Barbara
Flóra-Szekeres Barbara - avatar
+ 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.
13th Dec 2023, 9:42 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
I use ceil. But first we need to import from math library. from math import ceil print(ceil(p))
14th Dec 2023, 4:53 AM
Jaelani Kusuma
Jaelani Kusuma - avatar
+ 1
Thx, this is one of the most useful comment. 💖
14th Dec 2023, 6:45 PM
Flóra-Szekeres Barbara
Flóra-Szekeres Barbara - avatar