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 trialSHUYUN CHENG
2,509 PointsAre "total_due" and "total" two different variables or the same? Seems like they are treated like the same variable.
I know "total_due" and "total" mean the same thing. But would it be better to use just "total" or just "total_due" for the sake of consistency?
2 Answers
Taig Mac Carthy
8,139 PointsSHUYUN CHENG my guess is that the word "total" in the function "def split_check(total, number_of_people)" is meant to be simply a placeholder, so that you understand that the function "split_check" has two placeholders: one for the total and another one for the amount of people. Afterwords you can call the function with two values, such as "split_check(whatever, whatever) and the script would do its thing.
I tested it with Rick and Morty to see it this was the case, and it works fine.
import math
def split_check(total, number_of_people):
return math.ceil(total / number_of_people)
rick = float(input("What is the total? "))
morty = int(input("How many people? "))
amount_due = split_check(rick,morty)
print("Each person owes ${}".format(amount_due))
Aurelian Spodarec
10,801 PointsHaven't watch the video, nor I do Python, but this seems like misunderstanding what these words actually means.
The word 'due' amount is how much hasn't been paid. Total means... well the entire amount.
So if the total is $500, and you haven't paid anything, the total_due will be also $500.
So am assuming that you see that these two have the same value, but their action might be different.
Since this is a start, I'm assuming this is the first functionality you guys created, in the next videos (I guess) you will create some sort of system where you can pay off the total_due or something.
I would suggest to carry on with the tutorial, surery they will explain it later on.
Sometimes when I follow the tutorials I'm like shocked, waste 30minutes looking around, but realized that they explain it as soon as the next video starts.
That's just what I think :)
<noob />
17,062 Points<noob />
17,062 PointsHi!, u can name them whatever u want as long u understand their meaning. what's improtant when u name any variables in any language is that u should give them a meaningful name that describes their action. Final line is it all depends on u and as long u understand what each variable do u can name them even noobdeveloper XD