0

Halloween Candy

houses = int(input()) dollar = 2 if houses >= 3: print (int(dollar/houses*100)) How to round the output format? That is, round up percentages.

3rd May 2023, 5:38 PM
С A
10 Respuestas
+ 6
Rounding **up** (!!!) can be achieved with the ceil() function from the math module.
3rd May 2023, 5:56 PM
Lisa
Lisa - avatar
+ 5
I mean, for this task it is not necessary to check if houses >= 3 because it is defined that it will only ever be >= 3.
3rd May 2023, 5:50 PM
Lisa
Lisa - avatar
+ 4
Read the task description carefully: You are supposed to *round up*. And what happens when one inputs less than 3 houses?
3rd May 2023, 5:45 PM
Lisa
Lisa - avatar
+ 2
С A use ceil()
4th May 2023, 10:47 AM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 1
how to round percentages?
3rd May 2023, 5:55 PM
С A
+ 1
Looks like I haven't explored this section yet, thanks for the help.
3rd May 2023, 6:01 PM
С A
+ 1
С A Use round(num, decimals) function. Example: round(3.6184, 2) -> 3.62 round(381.837837, 3) -> 381.838
4th May 2023, 7:04 AM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 1
Thanks, I haven't taken the function courses yet, so I can't solve this problem.
4th May 2023, 10:11 AM
С A
+ 1
The task description asks us to ROUND UP, not to ROUND. Note the "up".
4th May 2023, 10:26 AM
Lisa
Lisa - avatar
0
it is not indicated what to do if there are fewer houses
3rd May 2023, 5:48 PM
С A