This Python program receives the price of a product and a discount percentage.
It sends these values to a method that calculates the discount amount and returns it.
The program then displays the calculated discount.
def calculate_discount(price: float, percent: float) -> float:
return price * percent / 100
# Read inputs from user
price = float(input("Enter product price: "))
percent = float(input("Enter discount percentage: "))
discount = calculate_discount(price, percent)
print(f"Discount amount: {discount:.2f} units")
Discount amount: 30000.00 units
- The user enters the product price and discount percentage
- These values are passed to a method that calculates the discount
- The method returns the result, which is displayed with two decimal places