Skip to content

Commit c741be4

Browse files
authored
Software Sales - Python , Tony Gaddis (Chapter 3 )
1 parent 72ab409 commit c741be4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

3.12. Software Sales.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
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
1818
package_price = 99
1919
# Get the User Input(the number of packages purchased) and Convert to int
2020
number_of_packages = int(input("Please Enter the number of packages"+\
2121
"purchased : "))
22-
2322
# check All the conditions
2423
if number_of_packages < 10:
2524
discount = 0
@@ -30,11 +29,13 @@
3029
elif number_of_packages < 100:
3130
discount = 0.3 # 0.3 is 30%
3231
else:
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"))
3940
print("total amount of the purchase after the discount is : $" + \
40-
format(total_amount, ",.2f"))
41+
format(total_amount, ",.2f"))

0 commit comments

Comments
 (0)