-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment.py
More file actions
37 lines (30 loc) · 1.29 KB
/
Copy pathAssignment.py
File metadata and controls
37 lines (30 loc) · 1.29 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
def calculate_discount(price, discount_percent):
# Is discount 20% or higher
if discount_percent >= 20:
# Calculate discounted price
discounted_price = price - (price * discount_percent / 100)
return discounted_price
else:
# If discount is less than 20%, return the original price
return price
# Example usage:
original_price = 100
discount_percent = 25
final_price = calculate_discount(original_price, discount_percent)
print("Final price after applying discount:", final_price)
def calculate_discount(price, discount_percent):
if discount_percent >= 20:
discounted_price = price - (price * discount_percent / 100)
return discounted_price
else:
return price
# Prompting the user to enter the original price and discount percentage
original_price = float(input("Enter the original price of the item: "))
discount_percent = float(input("Enter the discount percentage: "))
# Calculating the final price after applying the discount
final_price = calculate_discount(original_price, discount_percent)
# Printing the final price
if final_price != original_price:
print("Final price after applying discount:", final_price)
else:
print("No discount applied. Original price:", original_price)