-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloops.py
22 lines (20 loc) · 996 Bytes
/
loops.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Create a function named calculate_discount(price, discount_percent)
# that calculates the final price after applying a discount.
# The function should take the original price
# (price) and the discount percentage (discount_percent) as parameters.
# If the discount is 20% or higher, apply the discount; otherwise,
# return the original price.
# Using the calculate_discount function, prompt the user to enter the
# original price of an item and the discount percentage.
# Print the final price after applying the discount, or if no discount was applied,
# print the original price.
def calc_disc(price,discount_perc):
if discount_perc >= 20:
return price - (discount_perc/100)
else:
return price
price=float(input('Enter original price:'))
discount_perc=float(input('Enter discount percentage:'))
final_price = calc_disc(price, discount_perc)
# Print the final price
print("The final price after applying the discount is: ", final_price)