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

Halloween candy

Не могу понять, в чем косяк https://sololearn.com/coach/4/?ref=app houses = int(input()) shans = round((2/houses)*100) print(shans)

13th Apr 2022, 6:49 PM
Владимир Ершов
Владимир Ершов - avatar
3 Answers
+ 2
Владимир Ершов , since the task description says about output: "A percentage value rounded up to the nearest whole number.", we should use ceil() for rounding but not round(). to get access to ceil(), we have to import math module. happy coding!
13th Apr 2022, 7:02 PM
Lothar
Lothar - avatar
+ 2
Владимир Ершов , you are right: round() is rounding to the nearest whole number, but this can be rounding UP or rounding DOWN, depending on the value of the number. but task description is talking about to apply a rounding UP, which means that ceil() is the correct way to go.
13th Apr 2022, 8:13 PM
Lothar
Lothar - avatar
+ 1
Lothar thanks, but i thought, round() rounded to the ->nearest whole number<-. Hmm, mb translation mistake.
13th Apr 2022, 7:06 PM
Владимир Ершов
Владимир Ершов - avatar