[Tutor] FW: How do i show discount?(sorted)
ADRIAN KELLY
kellyadrian at hotmail.com
Sun Nov 20 00:38:42 CET 2011
From: kellyadrian at hotmail.com
To: kellyadrian at hotmail.com
Subject: RE: How do i show discount?
Date: Sat, 19 Nov 2011 23:34:27 +0000
sorted it guys, used a third function....
Adrian
From: kellyadrian at hotmail.com
To: tutor at python.org
Subject: How do i show discount?
Date: Sat, 19 Nov 2011 22:41:37 +0000
def shop(total_spend): min_spend=25 discount_amount=150 discount=0.05 if total_spend >= min_spend and total_spend > discount_amount: checkout=total_spend-(total_spend*discount) discount=total_spend*discount else: checkout = total_spend discount = 0 return checkout
def main(): spend = input('Enter the amount you spent: ') while spend<25: print "Error, min spend is €25 in this shop!" spend = input('Enter the amount you spent: ') else: total = shop(spend) print 'Your bill comes to',total,"\n","your discount was",discount
main ()
#program works but how would i show the discount in main? I saved as text file in notepad........! Many thanks!!!!!!!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111119/de94ce1a/attachment.html>
More information about the Tutor
mailing list