Objective
Create a Python program with a function that computes a final price and has optional parameters with a default value.
Instructions
- Define
def final_price(price, tax=21, discount=0). First apply the discount (percentage) and then the tax (percentage):price * (1 - discount / 100) * (1 + tax / 100). - Read a line with 1, 2 or 3 numbers separated by spaces: the price, and optionally the tax and the discount, in that order.
- Call the function only with the values you have received, so that the missing ones use their default value.
- Show
Final price: Pwith 2 decimals.
100
Final price: 121.00
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise