import promotion import starbuzz from transactions import * items = ["DONUT", "LATTE", "FILTER", "MUFFIN"] prices = [1.50, 2.0, 1.80, 1.20] running = True while running: option = 1 for choice in items: print(str(option) + " " + choice) option += 1 print(str(option) + ". Quit") choice = int(input("Choose an option: ")) if choice == option: running = False else: credit_card = int(input("Credit card number: ")) price = promotion.discount(prices[choice - 1]) if input("Starbuzz card? ") == "Y": price = starbuzz.discount(price) save_transactions(price, credit_card, items[choice - 1])
from transactions import * import promotion import starbuzz items = ["DONUT", "LATTE", "FILTER", "MUFFIN"] prices = [1.50, 2.0, 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: ") price=promotion.discount(prices[choice - 1]) if input("Starbuzz Card?") == "Y" : price = starbuzz.discount(price) save_transaction(price, credit_card, items[choice - 1])
from transactions import * #By importing the transactions module like this, you can call the functions without the module name. import promotion #You need to use this kind of import for “promotion.py” and “starbuzz.py”, because you are going to qualify the function names with the module names. import starbuzz items = ["DOUNT", "LATTE", "FILTER", "MUFFIN"] prices = [1.50, 2.0, 1.80, 1.20] running = True while running: #The loop will keep running while the "running" variable has the value True. To end the loop,set "running" to False. option = 1 for choice in items: print(str(option) + ". " + choice) option = option + 1 print(str(option) + ". Quit") choice = int(input("Choose an option: ") ) #The user inters a menu option number to make a sale. if choice == option: #This will be True if the user selects the LAST option on the menu, which is "Quit". running = False else: credit_card = input("Credit card number: ") price = promotion.discount( prices[choice - 1]) #Code will call the "discount()" function. if input("Starbuzz card? ") == "Y": price = starbuzz.discount( price ) #Id someone has a starbuzz discount card you need to apply the second starbuzz discount. save_transaction(price, credit_card, items[choice - 1]) #"price" is the discount value of the price.
items = ["DONUT", "LATTE", "FILTER", "MUFFIN"] prices = [1.50, 2.0, 1.80, 1.20] running = True starbuzz_discount = input("Do you have Starbuzz discount card? (Y/N) ") 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: ")) #inserisci un numero intero da 1 a 5 if choice == option: #cioè è uguale a 5 che corrisponde a quit running = False # chiude il programma else: credit_card = input( "Credit card number: " ) # se è una delle 4 precedenti conferma l'acquisto if Luhn(int( credit_card)) == 1: #chiamo la funzione Luhn dal modulo luhn if starbuzz_discount == "N": save_transaction( promotion.discount(prices[choice - 1]), credit_card, items[choice - 1]) #uso la funzione del modulo elif starbuzz_discount == "Y": save_transaction( starbuzz.discount(promotion.discount(prices[choice - 1])), credit_card, items[choice - 1]) else: running = False #se il codice non è valido chiude il programma
import promotion import starbuzz from transactions_2 import * items = ["DONUT", "LATTE", "FILTER", "MUFFIN"] prices = [1.50, 2.0, 1.80, 1.20] running=True starbuzz_discount=input("Do you have Starbuzz discount card? (Y/N) ") 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: ")) #inserisci un numero intero da 1 a 5 if choice==option: #cioè è uguale a 5 che corrisponde a quit running=False # chiude il programma else: credit_card=input("Credit card number: ") # se è una delle 4 precedenti conferma l'acquisto if starbuzz_discount=="N": save_transaction(promotion.discount(prices[choice - 1]), credit_card,items[choice -1] ) #uso la funzione del modulo elif starbuzz_discount=="Y": save_transaction(starbuzz.discount(promotion.discount(prices[choice - 1])), credit_card,items[choice -1] )
from transactions import * import promotion import starbuzzi items = ["DONUT", "LATTE", "FILTER", "MUFFIN"] prices = [1.50, 2.0, 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: ") discount_card = input("Starbuzz Discount Card?: Y/N ") if discount_card == "Y": card_price = starbuzzi.discount(prices[choice - 1]) new_price = promotion.discount(card_price) save_transaction(new_price, credit_card, items[choice - 1]) else: new_price = promotion.discount(prices[choice - 1]) save_transaction(new_price, credit_card, items[choice - 1])