print("%.2f" % total)

Stephane Wirtel stephane at wirtel.be
Sun Nov 22 02:01:02 EST 2015


print the two digits after the point.

On 11/21, Cai Gengyang wrote:
> 
> meal = 44.50
> tax = 0.0675
> tip = 0.15
> 
> meal = meal + meal * tax
> total = meal + meal * tip
> 
> print("%.2f" % total)   
> 
> What do the lines inside the parentheses in this statement print("%.2f" % total) mean ? 
> 
> What does "%.2f" % total represent ?
> 
> Thanks alot ...
> 
> Gengyang
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
Stéphane Wirtel - http://wirtel.be - @matrixise



More information about the Python-list mailing list