Question

In: Computer Science

Create a report that lists each topping and also lists the number of pizzas that used...

Create a report that lists each topping and also lists the number of pizzas that used that topping. Order the report in decreasing order of number of pizzas. That is, the most popular toppings will be at the top of the report.2 In each row of the table list: the topping name; the price of the topping; the number of pizzas that used the topping; and, the total value of the topping (number of pizzas times topping price). Since some toppings cost more than others, the total values may not be in descending order.3

Format the monetary amounts with two decimal places. Do this by using the fixed point formatting feature of the formatting method you choose. Do not try rounding the values mathematically.

ex. Gamalost    2.00    237          474.00

import sqlite3

class PizzaServices:

    def __init__(self):
        self.connection = sqlite3.connect("pizza-190807A.sqlite")

    def __enter__(self):
        return self

    def __exit__(self, exe_type, exc_val, exl_tb):
        crs = self.connection.cursor()

    def do_query(self, query, parameters=None):
        crs = self.connection.cursor()
        if parameters:
            crs.execute(query, parameters)
        else:
            crs.execute(query)

        return crs.fetchall()

    def customer(self):
        return self.do_query("select * from customer")

    def invoices_for_customer(self, customer_id):

    def pizzas_for_invoice(self, invoice_id):
        """
        returns a list of two items: pizza db row and a list of
            toppings id's for the pizza
        The pizza db row has pizza id, crust id, sauce id,
            combination id (None if this is a regular pizza) and invoice id
        :param invoice_id:
        :return:
        """

    def crust_for_id(self, crust_id):

    def sauce_for_id(self, sauce_id):

    def topping_for_id(self, topping_id):

    def pizza_for_id(self, pizza_id):

    def invoice_for_id(self, invoice_id):

Solutions

Expert Solution

with PizzaServices() as cs:
        cust = cs.customer()
        cmd1 = '''
                select topping.name, topping.price, count(pizzaTopping.pizzaId), count(pizzaTopping.pizzaId) * topping.price
                from pizzaTopping, topping 
                where
                pizzaTopping.toppingId = topping.toppingId 
                group by
                topping.name, topping.price
                order by
                count(pizzaTopping.pizzaId) desc
        '''
        resultSet = cs.do_query(cmd1)  # capture the result, It is a list of tuples

        templateH = "{:25} {:15} {:15} {:15}"
        line = templateH.format("Topping", "Unit Price", "Total Orders", "Total Value")
        print(line)

        for row in resultSet:                            
                print("{:25} {:<15} {:<15} {:<15}".format(row[0].strip(), row[1], row[2], row[3]))
                
                
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

Create a report that lists all the customers in alphabetical order by last name. The report...
Create a report that lists all the customers in alphabetical order by last name. The report should include first name, last name, and email address of all customers. This report involves getting data from one table. The three items should be lined up in columns. Use one of the formatting functions available through Python (the % operator or the format function). Don’t use tabs to line up columns, this does not reliably work and is inflexible.1 Even though we won’t...
Create a report that lists customers with the total value of their orders from the database....
Create a report that lists customers with the total value of their orders from the database. Each row of the table should list the customer name and the total value of all orders. Rows should be in descending order according to the total. Just list the first 5 customers, those with the highest total orders. This part is more complex and, so, can be approached in many ways. You may decide to use simple queries and put the information together...
create a questionaire that can be used to compile a report for the assignment below "The...
create a questionaire that can be used to compile a report for the assignment below "The students are expected to visit any company of their choice and find out how they do their maintenance budget. Conduct interviews with va rious levels of personnel. The student is expected to present a typed three- pages report (detailed report) toget her with the completed interview question with responses from the company maintenance personnel. Company maintenance budget must be attached to the report. Proof...
Access the annual report or 10-K for General Motors.Post a short report that lists the following...
Access the annual report or 10-K for General Motors.Post a short report that lists the following information as a reply to this thread. https://www.sec.gov/Archives/edgar/data/1467858/000146785817000028/gm201610k.htm Describe the inventory costing method that is used. Why do you think the company chose this method rather than the other acceptable methods? Are the inventory costs are rising or falling? Calculate the gross profit percentage at the end of the current and prior periods, and explain any change between the two years. Calculate the inventory...
You are ordering a hamburger and can get up to 88 toppings, but each topping can...
You are ordering a hamburger and can get up to 88 toppings, but each topping can only be used once. You tell the cashier to surprise you with the toppings you get. What is the probability that you get 33 toppings? Express your answer as a fraction or a decimal number rounded to four decimal places.
Create a 1 page overview of the financial report for each of the 3 companies (Ford,...
Create a 1 page overview of the financial report for each of the 3 companies (Ford, GM and Fiat Chrysler) Please go to the websites and pull up the financial reports
A pizza restaurant offers various kinds of toppings for you to choose from: (each topping can...
A pizza restaurant offers various kinds of toppings for you to choose from: (each topping can only be chosen at most once) Meat: Turkey, Bacon, Pepperoni, Chicken, Meatballs Vegetables and Fruits: Black Olives, Pineapple, Mushroom, Onion Cheese: Mozzarella, Parmesan a) How many pizzas with different toppings could you order if you can choose any number of the toppings available to include, including no toppings. b) How many different pizzas could you order if you must include at least two different...
Java Code. Using Decorator pattern make class BurgerToppings: -Each topping is an extra $1 and the...
Java Code. Using Decorator pattern make class BurgerToppings: -Each topping is an extra $1 and the name provided in the constructor -getTotalPrice: returns total price of burger + toppings -getDetails: returns the burger name + name of topping with the word (extra) Code: public interface Burger{ double C(); String getDetails(); } public class BigMac implements Burger{ private String order; private double price ; public BigMac() { this.order= "Big Mac"; this.price = 4.00; } @Override public double getPrice() { return price;...
Java Code. Using Decorator pattern make class BurgerToppings: -Each topping is an extra $1 and the...
Java Code. Using Decorator pattern make class BurgerToppings: -Each topping is an extra $1 and the name provided in the constructor -getTotalPrice: returns total price of burger + toppings -getDetails: returns the burger name + name of topping with the word (extra) Code: public interface Burger{ double C(); String getDetails(); } public class BigMac implements Burger{ private String order; private double price ; public BigMac() { this.order= "Big Mac"; this.price = 4.00; } @Override public double getPrice() { return price;...
Using C++, you will create a program, where you will create two doubly linked lists. These...
Using C++, you will create a program, where you will create two doubly linked lists. These doubly linked lists will contain integers within them. Using the numbers in both of these linked lists, you add the numbers together, and insert the addition of the two numbers into a singly linked list. the input can be from the user or you just write the input. for example, if one number in the doubly linked list is 817 and in the other...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT