-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcost.py
More file actions
25 lines (21 loc) · 908 Bytes
/
cost.py
File metadata and controls
25 lines (21 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def calculate_discount(price, discount_percent):
if discount_percent >= 20:
discount_amount = price * (discount_percent / 100)
final_price = price - discount_amount
else:
final_price = price
return final_price
def main():
# Prompt user for input
original_price = float(input("Enter the original price of the item: "))
discount_percent = float(input("Enter the discount percentage: "))
# Calculate final price using the calculate_discount function
final_price = calculate_discount(original_price, discount_percent)
# Display the final price
if final_price == original_price:
print(f"No discount applied. Final price: ${final_price:.2f}")
else:
print(f"Discount applied. Final price after {discount_percent}% discount: ${final_price:.2f}")
# Call the main function to run the program
if __name__ == "__main__":
main()