Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python question A grocery shopping program. The program receives input about products purchased, calculates the amount due and displays it back to the user #

python question

"""A grocery shopping program.

The program receives input about products purchased,

calculates the amount due and displays it back to the user"""

# Known products and their unit prices

GROCERY_PRICES = {

"tomato": 2.99,

"bread": 1.59,

"chicken": 10.78,

"beef": 15.69,

"potato": 5.47,

"apple": 1.57,

}

def get_amount_due(groceries):

"""Calculate the amount due for the specified list of groceries

The prices of the known products are provided in the GROCERY_PRICES

global variable

Args:

groceries(list): A list of groceries, each being a two-item tuple

containing the name of a product and the number of

items purchased

Returns:

float: The amount due

"""

# Your code goes here

pass

def main():

"""Get input from the user about the products purchased and

display the amount due on the screen.

The products must be one of the known products contained

in the GROCERY_PRICES global variable

The user is prompted for input continuously until they answer

'no' when asked to add another entry.

"""

# Your code goes here

pass

if __name__ == "__main__":

grocery_list = [

("tomato", 5),

("chicken", 1),

("potato", 2),

]

# get_amount_due

# amount = get_amount_due(grocery_list)

# print(amount)

# main program

# main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions