Answer:
def cost(quantity, unit_price, taxable):
if taxable == "Yes":
total = (quantity * unit_price) + (quantity * unit_price * 0.07)
elif taxable == "No":
total = quantity * unit_price
return total
q = int(input("Enter the quantity: "))
p = float(input("Enter the unit price: "))
t = input("Is %7 tax applicable? (Yes/No): ")
print(str("$" + str(cost(q, p, t))))
Explanation:
- Create a function called cost that takes three parameters, quantity, unit price, and taxable
- If the tax is applicable, calculate the total with tax. Otherwise, do not add the tax.
- Return the total
- Ask the user for the inputs
- Call the function with given inputs and print the result