Page 246 -
P. 246
modular programming
By importing the
transactions module like this, from transactions import *
you can call the functions
without the module name. import promotion
import starbuzz
You need to use this kind of
import for “promotion.py”
and “starbuzz.py”, because
you are going to qualify the items = [“DONUT", “LATTE", “FILTER", “MUFFIN"]
function names with the
module names. 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: ")
If someone has a price = promotion.discount(prices[choice - 1])
Starbuzz Discount
Card, you need to if input(“Starbuzz card? ") == “Y":
apply the second
Starbuzz discount. price = starbuzz.discount(price)
save_transaction(price, credit_card, items[choice - 1])
you are here 4 211