# Invoice.py # Instance Methods for a Class Object class Invoice: # define base attr def __init__(self, subtotal, tax_rate): self.subtotal = subtotal self.tax_rate = tax_rate # decimal 7% as .07 # Instance Methods ## Instance method to calculate tax bases on the subtotal def calculate_tax(self): # subtotal * tax_rate return self.subtotal * self.tax_rate # 100 * .07 # return 7 ## Instance method to calculate invoice total def calculate_total(self): return self.subtotal + self.calculate_tax() # 100 + return(7) ASSERTING 107 ## Instance method to display the invoice total def display_invoice(self): return f"Subtotal: ${self.subtotal:.2f} Tax: ${self.calculate_tax():.2f} Total: ${self.calculate_total():.2f}" ## Instance method to covert tax_rate to percentage def tax_asPerc(self): asPerc = self.tax_rate * 100 # .07 * 100 Assert 7 return f"Tax Rate: {asPerc:.2f}%" # 7.00% # Output invoice = Invoice(100, .07) # print the tax_rate as a percentage print(invoice.tax_asPerc()) # Tax: 7% print(invoice.display_invoice())