i'm trying to get my outputs to align. I used the tab function. But the prof says: "The code for this must not use tabs or spaces for alignment, but should instead use formatted output. "
I tried using format('10.2f')
to indicate the number of spaces I want and where to round, but i keep getting a syntax error.
I cant use str() because we havent learned those yet in the class. we've only covered tabs, spaces, and left, right, and center adjustments
Problemo dos: i need to round subtotal to the nearest penny before proceeding and then round tax to the nearest penny before proceeding. but then i do
format(Subtotal= subPot + petPri + bagPri, '.1f')
i get
positional argument follows keyword argument
and when I try
Tax = Subtotal * TAX_RATE, format(Subtotal, '.1f'),
I get:
unsupported operand type(s) for +: 'float' and 'tuple'
This is my code:
# Calculations for overall total price
Subtotal = subPot + petPri + bagPri
Tax = Subtotal * TAX_RATE
TOTAL = Subtotal + Tax
# Output
print ("-----------------------------------------------")
print ("Supplies and Pricing for Order", userOrder,)
print ()
print ("Number of small pots: \t", int(smlPot),)
print ("Number of medium pots: \t", int(medPot),)
print ("Number of large pots: \t", int(larPot),)
print ()
print ("Petunias:", int(totPet), "plants")
print ("Potting soil:", math.ceil(totBag), "bags")
print ()
print ("Subtotal\t""$""\t", format(Subtotal, ',.2f'))
print ("Tax\t\t""$""\t", format(Tax, ',.2f'))
print ("TOTAL\t\t""$""\t" , format(TOTAL, ',.2f'))
print ("-----------------------------------------------")
I want to align everything without using tab or spaces. It should look like this:
--------------------------------------------------
Supplies and Pricing for Order 1234
Number of small pots: 5
Number of medium pots: 6
Number of large pots: 7
Petunias: 101 plants
Potting soil: 4 bags
Subtotal $ 123.45
Tax $ 18.56
TOTAL $ 234.78
--------------------------------------------------