Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started