The health club has a new requirement

The health club boss has a grand plan to get more customers into the health club.

Ooh, I think we need to discount the prices in the coffee bar for the next month. There's nothing like relaxing with a latte after a tough workout, especially if the price is right. Our customers like to treat themselves, so I want to make this easy for them.

The boss has a great new idea.

The boss wants to cut 10% off all the prices in the coffee bar. If it's successful, he may want to do the same thing in other places, such as the gym.

Instead of just amending the code in the coffee pos . py file, you need to create a new module called promotion. py that will calculate a discounted price.

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

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

def discount(price):

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

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])

discount applied

You needed to change the coffee bar POS program to apply the 10% discount to everything that's sold. You had three tasks.

'I Start by creating a new module called promotion. py containing ^^ one function:

def discount(price):

return 0.9 * price

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

©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 * You need to import the ¿ode r ,. . _______from the "promotionpy module-

from promotion 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:

Your Code should call the "discounts"

credit card = input("Credit card number: ")

save transaction(pri/ce-s-[chQice^—vl], credit card, items[choice - 1])

new_priCe^^Vw_price» is the discounted value of the priCe.

Was this article helpful?

0 0

Post a comment