1414(1) Starting out with Python, Third Edition, Tony Gaddis Chapter 3
1515(2) https://youtu.be/0qHWyPWhZO4
1616"""
17- # give value
17+ # given a package retails
1818package_price = 99
1919# Get the User Input(the number of packages purchased) and Convert to int
2020number_of_packages = int (input ("Please Enter the number of packages" + \
2121 "purchased : " ))
22-
2322# check All the conditions
2423if number_of_packages < 10 :
2524 discount = 0
3029elif number_of_packages < 100 :
3130 discount = 0.3 # 0.3 is 30%
3231else :
33- discount = 0.4 # 0.4 is 20 %
32+ discount = 0.4 # 0.4 is 40 %
3433# 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
3737# 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" ))
3940print ("total amount of the purchase after the discount is : $" + \
40- format (total_amount , ",.2f" ))
41+ format (total_amount , ",.2f" ))
0 commit comments