14
14
(1) Starting out with Python, Third Edition, Tony Gaddis Chapter 3
15
15
(2) https://youtu.be/0qHWyPWhZO4
16
16
"""
17
- # give value
17
+ # given a package retails
18
18
package_price = 99
19
19
# Get the User Input(the number of packages purchased) and Convert to int
20
20
number_of_packages = int (input ("Please Enter the number of packages" + \
21
21
"purchased : " ))
22
-
23
22
# check All the conditions
24
23
if number_of_packages < 10 :
25
24
discount = 0
30
29
elif number_of_packages < 100 :
31
30
discount = 0.3 # 0.3 is 30%
32
31
else :
33
- discount = 0.4 # 0.4 is 20 %
32
+ discount = 0.4 # 0.4 is 40 %
34
33
# Calculate the discount amount and total amount
35
- total_amount = number_of_packages * package_price
36
- discount_amount = number_of_packages * discount
34
+ sub_total = number_of_packages * package_price
35
+ discount_amount = sub_total * discount
36
+ total_amount = sub_total - discount_amount
37
37
# Display the Result
38
- print ("the amount of the discount is : $" + format (discount , ",.2f" ))
38
+ print ("the amount of the discount is : $" + \
39
+ format (discount_amount , ",.2f" ))
39
40
print ("total amount of the purchase after the discount is : $" + \
40
- format (total_amount , ",.2f" ))
41
+ format (total_amount , ",.2f" ))
0 commit comments