Update

I am trying to round a float to two decimals.
>
> Basically, I am writing a program to ask a user how many square feet they
> need to paint. I then calculate how many cans of paint they need and will
> also show the total purchase price. I've tried this two ways, and both ways
> I am semi-successful meaning that my output is rounding but it displays a
> number of zero's after the number rounds. How can I make the zero's stop
> displaying?
>



>         total = PRICE_PER_CAN * cans + (PRICE_PER_CAN * cans * TAX)
>         total = round(total,2)
>         print 'For %d square feet, you\'ll need %d cans of paint.'
> %(square_feet, cans)
>         print 'That will cost you $%f.' %(total)
>
>
>
>         total = PRICE_PER_CAN * cans + (PRICE_PER_CAN * cans * TAX)
>         print 'For %d square feet, you\'ll need %d cans of paint.'
> %(square_feet, cans)
>         print 'That will cost you $%f.' %round(total,2)
>
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to