Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

''' The task is broken down into three sections. Section 1 - User Input Section 2 - loop through the grocery list Section 3 -

'''

The task is broken down into three sections. Section 1 - User Input Section 2 - loop through the grocery list Section 3 - provide output to the console '''

#Task: Create the empty data structure grocery_item = ?

grocery_history = ?

#Variable used to check if the while loop condition is met stop = 'go'

while ?????? :

#Accept input of the name of the grocery item purchased. #Accept input of the quantity of the grocery item purchased. #Accept input of the cost of the grocery item input (this is a per-item cost).

#Create a dictionary entry which contains the name, number and price entered by the user.

#Add the grocery_item to the grocery_history list using the append function

#Accept input from the user asking if they have finished entering grocery items.

# Define variable to hold grand total called 'grand_total'

#Define a 'for' loop.

for ??????? in ?????????: #Calculate the total cost for the grocery_item. #Add the item_total to the grand_total #Output the information for the grocery item to match this example: #2 apple @ $1.49 ea $2.98 #Set the item_total equal to 0

#Print the grand total

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Data Structure The structure of the data for this project is extremely important. Each grocery item is a dictionary with the following key-value pairs a name of the grocery item with the key identifier 'name' the number of grocery items purchased with the key identifier 'number the cost of the grocery item with the key identifier'price 'name' 'milk', 'number': int(1), 'price': float (2.99) grocery_history is a list of grocery item dictionary elements. grocery_history-L'name' 'milk', 'number int(1), 'price' float (2.99), 'name': 'eggs''number': 2, 'price': 3.99 'name' onions', 'number': 4, 'price': 0.791 Task: Create the empty data structure 1. Create an empty dictionary with the variable name grocery_item 2. Create an empty list with the variable name grocery_history

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions