Skip to content

Abdallah-M84/Week_3_Assignment_Discount_calc._function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

define discount function

def calculate_discount(price, discount_percent):

Check if the discount is 20% or higher

if discount_percent >= 20:

Calculate the discounted price

    discount_amount = price * (discount_percent / 100)
    final_price = price - discount_amount
    return final_price
else:

If discount is less than 20%, return the original price

    return price

Prompt the user for the original price and discount percentage

try:

original_price = float(input("Enter the original price of the item: "))
discount_percentage = float(input("Enter the discount percentage: "))

Calculate the final price

final_price = calculate_discount(original_price, discount_percentage)

Print the result

if final_price == original_price:
    print(f"No discount applied. The final price is: ${original_price:.2f}")
else:
    print(f"Discount applied! The final price is: ${final_price:.2f}")

except ValueError:
   print("Please enter valid numerical values.")

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published