Question & Answer: Purpose: To practice list operations such as adding. removing and finding indices Degree of Difficulty: Moderate The Sesame…..

Language: Python

Program required: Processing 3.0

Purpose: To practice list operations such as adding. removing and finding indices Degree of Difficulty: Moderate The Sesame Street Bakery sells four items at the following prices . Bread ($5) . Doughnut ($2) . Muffin (S3) . Cookie ($1) For this question, you will write a program that allows the user to place an order at the bakery. Here is how your program should behave . Use a 500x500 white canvas as your background . On the left side of the canvas, display the bakerys menu, which consists of the name and price of each item . On the right side of the canvas, display all of the items in the users order so far. Initially, the order will be empty. It is okay if the order gets too big for the screen: you dont need to handle this case Below the users order, display the total cost of the entire order. Initially the cost is O でfor Cookie, etc..) ·When the user presses the b, d, m orでkeys: Add the appropriate item to the order (b for Bread » When the user presses the u (for undo) key: Remove the most recently-added item from the order and adjust the total cost accordingly Menu Your order Bread: $5 Doughnut: $2 Muffin: $3 COOKIE: $1 Bread Doughnut COOkIE Doughnut COOKIE COOKIE COOKIE Cost: $16 Figure 2: A sample order It is not possible to solve this question without making at least some use of lists (in particular, you will need a list to store the order). However, to get full marks for this question, you must make effective use of lists beyond the bare minimum in the following ways

Purpose: To practice list operations such as adding. removing and finding indices Degree of Difficulty: Moderate The Sesame Street Bakery sells four items at the following prices . Bread ($5) . Doughnut ($2) . Muffin (S3) . Cookie ($1) For this question, you will write a program that allows the user to place an order at the bakery. Here is how your program should behave . Use a 500×500 white canvas as your background . On the left side of the canvas, display the bakery’s menu, which consists of the name and price of each item . On the right side of the canvas, display all of the items in the user’s order so far. Initially, the order will be empty. It is okay if the order gets too big for the screen: you don’t need to handle this case Below the user’s order, display the total cost of the entire order. Initially the cost is O でfor Cookie, etc..) ·When the user presses the ‘b, ‘d’, ‘m’ orでkeys: Add the appropriate item to the order (‘b’ for Bread » When the user presses the ‘u’ (for “undo”) key: Remove the most recently-added item from the order and adjust the total cost accordingly Menu Your order Bread: $5 Doughnut: $2 Muffin: $3 COOKIE: $1 Bread Doughnut COOkIE Doughnut COOKIE COOKIE COOKIE Cost: $16 Figure 2: A sample order It is not possible to solve this question without making at least some use of lists (in particular, you will need a list to store the order). However, to get full marks for this question, you must make effective use of lists beyond the bare minimum in the following ways

Expert Answer

 

Answer for the given Question:

See the below python code for given problem statement. which may helpful to given statement

import pandas as pd

pizzas = [
    "Hawaiian",
    "Champagne Ham & Cheese",
    "Beef & Onion",
    "Pepperoni",
    "Simply Cheese",
    "Bacon & Mushroom",
    "Italiano",
    "The Deluxe",
    "Ham, Egg & Hollandaise",
    "Americano",
    "Mr Wedge",
    "BBQ Meatlovers"
    ]

df = pd.DataFrame(pizzas, columns=["Pizzas"])
df.loc[:8, "Prices"] = 7.50     # First 7 items.
df.loc[8:, "Prices"] = 13.50    # All the rest.
df.index += 1                   # So that it's not zero-indexed.
total_bill = 0.0                # Meh.

print "Welcome to Pizza Planet!" # So unoriginal, I know.
print
print "Here's our menu!"
print
# Following method taken and modified from unutbu's amazing answer
# here: http://stackoverflow.com/questions/25777037
print df.to_string(justify='left',
                   header=False,
                   formatters={
                    'Pizzas':'{{:<{}s}}'.format(
                        df['Pizzas'].str.len().max()
                        ).format,
                    'Prices':'     ${:.2f}'.format})
print
print "Input a number and press enter to select an item."
print "Input 'done' to finish your order and tabulate your bill."
print "Input 'exit' to cancel your orders."

while True:

    order = raw_input(">>>  ")

    if order == 'exit':
        break
    elif order == 'done':
        print "Your total bill is ${:.2f}.".format(total_bill)
        raw_input("Press any key to exit.")
        break
    elif int(order) in df.index:
        item = df.loc[int(order), "Pizzas"]     # Get the respective items
        price = df.loc[int(order), "Prices"]    # by indexing order input.
        print "You've selected {}! That would be ${:.2f}.".format(item, price)
        total_bill += price
        continue
    else:
        print "Don't be an idiot." # :-)
        raw_input("Press any key to exit.")
        break
Still stressed from student homework?
Get quality assistance from academic writers!