Write it in python. Check the example properly. You have been hired as an app developer for the company. The company plans to make an app for a grocery store where the user can order groceries and see the total amount to be paid in the cart section. To build this feature, you have to write a function that takes 2 arguments. They are: order_items (must be a list) location (default value should be set to "Dhanmondi") Your first task is to take a list of items from the user. Pass the list into the function parameter along with the optional location (Use default argument technique). (Also, no need to take location as input, pass this any value you want.) Your second task is to implement the function. In the function, create a dictionary for the items shown in the table. Calculate the total price of the items passed as a list to the function. Additionally, add a delivery fee of 30 taka if the location is Dhanmondi. Otherwise, add a delivery fee of 70 taka. Finally, return the value and print it

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write it in python. Check the example properly.

You have been hired as an app developer for the company. The company plans to make an app for a grocery store where the user can order groceries and see the total amount to be paid in the cart section.

To build this feature, you have to write a function that takes 2 arguments. They are:

  • order_items (must be a list)
  • location (default value should be set to "Dhanmondi")

Your first task is to take a list of items from the user. Pass the list into the function parameter along with the optional location (Use default argument technique). (Also, no need to take location as input, pass this any value you want.)

Your second task is to implement the function. In the function, create a dictionary for the items shown in the table. Calculate the total price of the items passed as a list to the function. Additionally, add a delivery fee of 30 taka if the location is Dhanmondi. Otherwise, add a delivery fee of 70 taka. Finally, return the value and print it.

Item Price(Tk)
Rice 105
Potato 20
Chicken 250
Beef 510
Oil 85

=====================================================

Hint: The keys are the items and values are the corresponding price. Iterate the items in the list and check if the items in the list are available in the dictionary keys or not. If it is available, add the price.

=====================================================

Example1:
function_name(["Rice", "Beef", "Rice"], "Mohakhali")

total = 105 + 510 + 105 = 720 (Take the price of each item and add them.)
total = 720 + 70 = 790 (Finally, add the delivery fee based on the location.)

Input:
["Rice", "Beef", "Rice"]
Function Call:
function_name(["Rice", "Beef", "Rice"], "Mohakhali")
Output:
790

==============================================

Example2:

function_name(["Rice", "Beef", "Rice"])

total = 105 + 510 + 105 = 720 (Take the price of each item and add them.)
total = 720 + 30 = 750 (Since no location is passed in the parameter, it will use the default location-"Dhanmondi". For dhanmondi, delivery fee of 30 taka)

Input:
["Rice", "Beef", "Rice"]
Function Call:
function_name(["Rice", "Beef", "Rice"])
Output:
750

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Types of Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education