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)
![Nick Jahanshahi](https://secure.gravatar.com/avatar/cc317f0483f44dc30598a8a0df6eeb9e?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nick Jahanshahi
1,499 PointsWhat does split_check have ‘total’ in parenthesis but we never use total again?
I though we have to use the parameters in the parenthesis after defining a function, but we never see ‘total’ again???
2 Answers
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsI see total
being referenced in the math.ceil()
call in the return
statement, line 7. Yes?
![Unsubscribed User](https://secure.gravatar.com/avatar/13daaedf6c01fa3a9b434c81fd6532ed?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Unsubscribed User
523 PointsI would really appreciate even more insight into Why total and Total due connect? I get that you can write code to connect it as you explained but my question is not about how to write the code but rather why it works? Is it because total is a word that is within total_due? Would the same apply if we named it apples and apples_due? or any combination of words for that matter so long as the first words match?
example : oranges and oranges_due
assuming we used the same structure but replaced the words total with oranges. and can we also swap out the word due? for example oranges and oranges_eaten. ?
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsThe specific text used as the label name is irrelevant. In generic terms, the function’s parameters could be named (labeled) as param0
, param1
, etc., and the arguments in the call to the function could be named arg0
, arg1
, etc., then the parser makes the one-to-one connection based on the order of the labels. This is done independently of the text used for the labels.
Nick Jahanshahi
1,499 PointsNick Jahanshahi
1,499 PointsThanks Chris for replying Chris!
But how does the code know what ‘total’ is? I can see an input for number_of _people, but not for total (only total_due).
Thanks
Chris Freeman
Treehouse Moderator 68,425 PointsChris Freeman
Treehouse Moderator 68,425 PointsThe connection is made in pairing the calling arguments from line 12, with the function’s signature containing the function’s parameters in line 4. All of these are merely labels that get assigned to point at objects.
The calling arguments
total_due
andnumber_of_people
are labels defined at thecheck_please
module level to point to theinput
results.The receiving parameters
total
andnumber_of_people
are local to the function and are labels that point to the same object as the calling parameter labels. This is why Python is called a “pass by object reference” language.So the function’s local
total
will point at the same value as the passed intotal_due
points to.This may be a deeper than you expected, but understanding this will help make much of Python make sense.
Happy to add more details as needed.
Chris Freeman
Treehouse Moderator 68,425 PointsChris Freeman
Treehouse Moderator 68,425 PointsAn experiment to try:
print(id(total_due))
after line 11 to see where that object is located in memoryprint(id(total))
to see where the object pointed at by the local label is stored in memoryVoilà! Both labels point to the same object!!
Nick Jahanshahi
1,499 PointsNick Jahanshahi
1,499 PointsOk thanks Chris, this is super helpful.
You’re right, it’s slightly outside of my understanding at this point, but it has given me something to chew on for sure.
Thanks so much for you help!