Since your discount is calculated from the total purchase, you do not need to ask for it.
Discount calculations are done using conditional if statements.
Do not use % as a variable name!
All calculations are simple, no need for "from math import *"
bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184
You are almost there, please try to understand the logic here ...
[php]def calc_discount(cost):
if cost > 1000.00:
discount = cost * 0.1 # 10%
return discount
elif cost > 500.00:
discount = cost * 0.05 # 5%
return discount
else:
# no discount
return 0.0
[/php]
Once you know the cost of the purchase then discount = calc_discount(cost) and your final cost will be cost - discount. Not really rocket science, but very simple algebra!
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417