Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Joseph Heckert](https://secure.gravatar.com/avatar/55011da2c1ce45a9d4ce5ce53514561f?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Joseph Heckert
Python Development Techdegree Student 3,908 PointsBest Practice for math.ceil() placement?
I wondered... Is there some kind of a best practice for where to put the math.ceil() function? In the video, Craig wrapped the total / number_of_people calculation in the math.ceil() function - I wondered if there's a reason to do it there instead of in the return line like this:
def split_check(total, number_of_people):
cost_per_person = total / number_of_people
return math.ceil(cost_per_person)
1 Answer
![Travis Alstrand](https://uploads.teamtreehouse.com/production/profile-photos/11658224/micro_travis.jpg)
Travis Alstrand
Data Analysis Techdegree Graduate 49,407 PointsHey Joseph Heckert !
Thanks for sharing your question! For future posts, remember there is a Markdown Cheatsheet provided here. If you wrap your code inside of triple backticks it makes it a bit easier to read
def split_check(total, number_of_people):
cost_per_person = total / number_of_people
return math.ceil(cost_per_person)
What you proposed will give the same result as
def split_check(total, number_of_people):
return math.ceil(total / number_of_people)
It's just saving an extra line of code and another variable being created. People that are more familiar with programming may go for an approach like this second code block, but both work just fine.
If the top code block is easier for you to understand and/or read, then I'd recommend going that route. Eventually, when you're more familiar with these types of things you'll most likely start typing out the 2nd approach without even realizing it.