[Tutor] Field Width

Jenny Allar jennyallar at gmail.com
Wed Sep 18 18:50:51 CEST 2013


I'm only a few days in to learning Python, so please bear with me.

I need to line up the decimals on the printed information but I cannot get
the text to look uniform at all.


Here is my code:

def main():

    # Set up constants for cost per yard, flat fee, and tax rate
    cost_carpet = 5.50
    fee = 25
    tax = .06

    # Ask for yards needed
    yards_needed = float(input('Please enter the total number of yards
needed '))

    # Calculate subtotal
    subtotal = yards_needed * cost_carpet + fee

    # Calculate tax_rate
    tax_rate = subtotal * tax

    # Calculate total_due
    total_due = subtotal + tax_rate

     # Print blank line
    print()

    # Print infomation
    print("The cost of the carpet is $", format(subtotal,'9,.2f'))
    print("The flat fee is $", format(fee,'9,.2f'))
    print("The tax is $", format(tax_rate,'9,.2f'))
    print("The total due is $", format(total_due,'9,.2f'))


main ()




Thank you in advance,
Jenny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130918/4bcabc75/attachment.html>


More information about the Tutor mailing list