Reference no: EM132236346
Project - Grocery List
Introduction - Your task for this project is to create a very simple grocery list script. This script also emphasizes the importance of using lists, dictionaries and loop types within your script and how the use of those functions shapes your approach in creating a script.
The task is broken down into three sections:
1. User Input
2. Loop through the grocery list
3. Provide output to the console
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'
grocery_history is a list of grocery item dictionary elements.
Task: Create the empty data structure
1. Create an empty dictionary with the variable name grocery_item.
2. Create an empty grocery_history list.
Grocery List Script -
Prompt - The list object type is one of the most important and frequently used types in a Python program. A list is a container, an object that groups related objects together. A list is also a sequence: The contained objects maintain a left-to-right positional ordering. Elements of the list can be accessed via indexing operations that specify the position of the desired element in the list. Each element in a list can be a different type, such as string, integer, float, or even other list.
A dictionary is another type of container object that is different from sequences like strings, tuples, and lists. Dictionaries contain references to objects as key- value pairs: Each key in the dictionary is associated with a value, much like each word in an English language dictionary is associated with a definition. Unlike sequences, the elements of a dictionary do not have a relative ordering of positions. Adding a value to a dictionary can be done either with brackets or using the keyword dict.
A programmer can use loops to execute the same code repeatedly as long as some condition is true. The loop expression is evaluated when the program reaches the loop statement. If the loop expression is true, then the indented code block, known as the loop body, is executed. At the end of the loop body, execution goes back to the while loop statement. The loop expression is evaluated again, and if true, the loop body is executed again. But, if the expression evaluates to false, then execution instead proceeds to code below the loop body. Each execution of the loop body is called an iteration, and looping is also called iterating.
Your task for this project is to create a very simple grocery list script. This script emphasizes the importance of using lists, dictionaries, and loop types within your script, and how the use of those functions shapes your approach to creating a script.
You will be working on this project in the Project Two: Grocery List Script module in Codio. Following the directions in that module, you will also be able to determine the exact placement of the comments you will need to make in the code. Follow the directions in the module in Codio to walk through the activity.
Your script and word response for this script should address the following critical elements:
I. In Your Script (Annotated Text File):
Refer to the directions in the module in Codio for how to export out and comment your completed script.
A. Identify examples of four uses of list operations in the script using comments in your code. Be sure your examples address each of the following:
i. Creating lists
ii. Adding and removing data from a list
iii. Accessing values in a list
iv. Modifying values in a list
B. Identify examples of four uses of dictionary operations using comments in your code. Be sure your examples address each of the following:
i. Creating dictionaries
ii. Adding and removing key-value pairs
iii. Accessing values using keys
iv. Modifying values
C. Identify examples of three uses of loop structures using comments in your code. Be sure your examples address each of the following:
i. Item-based for loops
ii. Index-based (range) for loops
iii. While loops
II. Applying Your Experience
Making mistakes when you learn to write code is common. It is part of learning. What is important is developing the skill of learning how to understand your errors and then fix them (debugging). For this part of your final project, you will respond to the following:
A. Reflecting on your experience with this activity, explain the importance of knowing how and when to use lists, dictionaries, and loop types.
Support your response with examples from the activity of the types of errors and your method for fixing them.
Note - This is a codio project. In addition to notes provided, which are there to explain the steps necessary to complete the project, explain each step of the process. Also need a 1 paragraph reflection on all of the problems that were encountered and what was learned through the process.
Attachment:- Assignment File.rar