Applications of Argument Syntax
Drag and drop the options to the blanks to complete the program to perform a task using extended argument syntax.
Make a function to calculate the price of a product after discount. The function should take the price of the product, quantity and the discount percentage as arguments. If the quantity is not provided, it should be assumed to be 1. If the discount percentage is not provided, it should be assumed to be 10%.
Sample outputs
calculatePrice(100, 2, 20) # 160 calculatePrice(100, 2) # 180 calculatePrice(100) # 90
Complete the program
def calculatePrice(price,
,
): discountAmount = price * (discount / 100) return
print("Final Price: " + str(calculatePrice(100, 2, 20))) print("Final Price: " + str(calculatePrice(100, 2))) print("Final Price: " + str(calculatePrice(100)))
quantity = 1
(price - discountAmount)*quantity
discount = 10
quantity = 10
discountAmount*quantity
discount = 1
The same application without extended argument syntax
Complete the experiment first!