-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDiscount.py
34 lines (24 loc) · 1023 Bytes
/
Discount.py
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
# Program to find the Discount
def CalDis(price,per):
discount = (price) * (per/100)
PriceAfterDisc = price - discount
return PriceAfterDisc
price = float(input("Enter the Price of the Commodity: "))
per = float(input("Enter the Percent of discount of the Commodity: "))
print(f"The Price after discount is {CalDis(price,per)} ")
#Including Value error
# def CalDis(price,per):
# discount = (price) * (per/100)
# PriceAfterDisc = price - discount
# return PriceAfterDisc
# try:
# price = float(input("Enter the Price of the Commodity: "))
# if price < 0:
# raise ValueError("Please input price more than zero")
# per = float(input("Enter the Percent of discount of the Commodity: "))
# if per < 0:
# raise ValueError("Please input percentage more than zero")
# discountedPrice = CalDis(price,per)
# print(f"The Price after Discount is {discountedPrice:.2f}")
# except ValueError as e:
# raise ValueError(f"Error: Invalid Input {e} ")