Can someone explain '% bill' this part?


can someone explain '% bill' this part?

it was used in the tip calculator.


Hi John,
I just joined today and started. What exactly is the problem you are having? I may or may not be abel to help but I will try, you may be able to help me at somepoint as well :smile:


Not sure if you meant this line
print("%.2f" % total)

if so this is saying to print the variable total(which was defined earlier in the code)

and the %2f is saying to print total as a floating number with 2 decimal points


It's just saying that 'use the value of bill'.

When you use bill, you write it as:

print "This is a value: %d" % bill

If you have more than one value, you'll write something like this:

print "These are values: %d %d" % (onevalue, othervalue)

This is assuming that bill is a variable, as well as onevalue and othervalue.


Also, if you know C, then it's similar to calls to printf.

printf("This is a value: %d", bill);
is the same as
print "This is a value: %d" % bill


Got it ! thank you so much :smiley:


hi maherpa2,
cst1992 explained it below. Thats exactly what i was looking for. But thank you. :smiley: