Page 236 -
P. 236

modular programming




                                             You need to change the coffee bar POS program to apply the 10%
                                             discount to everything that’s sold. You have three tasks.



              1    Start by creating a new module called promotion.py containing
                   one function:

                       def discount(price):




              2    Complete the code in the above function so that it returns 90% of the price it is
                   given.



              3    This is the latest version of the coffee_pos.py module. Modify it so that it
                   uses the new module to cut the price of everything that’s sold.


               from transactions import *


               items   = ["DONUT", "LATTE", "FILTER", "MUFFIN"]
               prices  = [1.50, 2.20, 1.80, 1.20]
               running = True


               while running:
                   option = 1
                   for choice in items:
                       print(str(option) + ". " + choice)
                       option = option + 1
                   print(str(option) + ". Quit")
                   choice = int(input("Choose an option: "))
                   if choice == option:
                       running = False
                   else:
                       credit_card = input("Credit card number: ")
                       save_transaction(prices[choice - 1], credit_card, items[choice - 1])






                                                                                      you are here 4    201
   231   232   233   234   235   236   237   238   239   240   241