# Quick Question

#1

When reassigning a variable, how does python distinguish between them?
For example:

``````meal = 44.50
tax = 6.75 / 100
tip = 15.0 / 100

meal = meal + meal * tax
total = meal + meal * tip

print("%.2f" % total)
``````

How does python distinguish between `meal = 44.50` and `meal = meal + meal * tax`?

#2

define distinguish

we declare a variable named meal and give it a value of 44.50

then we re-assign meal variable and give it a value of `meal + meal * tax`, for this calculation the current value of meal (44.50) is used.

so after re-assigning `meal` will have a new value

#3

The old value is discarded when you no longer have a reference to it

#4

I donâ€™t think the tip calculator is accurate. This is more accurate:

``````   meal = 44.50
tax = .0675
tip = .15
subtotal = meal + meal * tax
actualtip = meal * tip
total = subtotal + actualtip
print(total)
``````

#5

this is certainly not accurate, now the tip is paid over the meal cost exclusive tax. Its custom that the tip is paid over the meal cost inclusive tax

#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.