"Shopping Cart" Project
Learning Objectives
Create a tool to facilitate and streamline a real-world business process.
Practice processing and validating user inputs in Python.
Reinforce introductory Python programming language concepts such as datatypes, functions, variables, and loops.
Practice incorporating version control into your development process.
Business Prompt
Your local corner grocery store has hired you as a technology consultant to help modernize their checkout system.
Currently, when managing inventory, store employees affix a price tag sticker on each grocery item in stock. And when a customer visits the checkout counter with their selected items, a checkout clerk uses a calculator to add product prices, calculate tax, and calculate the total amount due.
Instead, the store owner describes a desired checkout process which involves the checkout clerk scanning each product's barcode to automatically lookup prices, perform tax and total calculations, and print a customer receipt. To facilitate this process, the store owner has authorized the purchase of a few inexpensive barcode scanners, as well as checkout computers capable of running Python applications.
The store owner says it would be "acceptable but not preferable" to manage the inventory of products via the application's source code, that it would be "better" to manage the inventory of products via a local CSV file stored on the checkout computer, and that it would be "ideal" to be able to manage the inventory of products via a centralized Google Sheet spreadsheet document.
The store owner also says it would be "nice to have" a feature which prompts the checkout clerk or the customer to input the customer's email address in order to send them a receipt via email. And that it would be "ideal" to also save the customer's email addresses somewhere (if the customer consents to opt-in to the customer loyalty program).
Instructions
Iteratively develop a Python application which satisfies the store owner's objectives, as described in more detail by the "Basic Requirements" below.
Before attempting to implement the basic requirements, take some time to configure your project repository according to the "Setup" instructions below. After doing so, you'll have a remote repo on GitHub and a local copy on your computer within which to develop.
When developing, as you reach key milestones, use the command-line or GitHub Desktop software to intermittently "commit", or save new versions of, your code. And remember to push / sync / upload your work back up to your remote project repository on GitHub at least once before you're done.
If you are able to implement the basic requirements with relative ease, or if you are interested in a challenge, consider addressing one or more of the "Further Exploration Challenges". Otherwise, if you need help breaking the problem up into more manageable pieces, consult the "Guided Checkpoints". And if you would like a narrated walkthrough, consult the "Guided Screencast".
Setup
Repo Setup
Use the GitHub online interface to create a new remote project repository called something like "shopping-cart". When prompted by the GitHub online interface, let's get in the habit of adding a "README.md" file and a Python-flavored ".gitignore" file (and also optionally a "LICENSE") during the repo creation process. After this process is complete, you should be able to view the repo on GitHub at an address like https://github.com/YOUR_USERNAME/shopping-cart
.
After creating the remote repo, use GitHub Desktop software or the command-line to download or "clone" it onto your computer. Choose a familiar download location like the Desktop.
After cloning the repo, navigate there from the command-line:
Use your text editor or the command-line to create a file in that repo called "shopping_cart.py", and then place the following contents inside:
Make sure to save Python files like this whenever you're done editing them. After setting up a virtual environment, we will be ready to run this file.
Environment Setup
It is possible to complete this project using the "base" Anaconda environment, because the basic requirements don't require any third-party packages. However if you eventually end up tackling bonus challenges that require third-party packages, then you'll want to create and activate a new Anaconda virtual environment, and use a "requirements.txt" file approach to installing your packages:
Within an active virtual environment of choice ("base" or project-specific), demonstrate your ability to run the Python script from the command-line:
If you see the provided "products" data structure, you're ready to move on to project development. This would be a great time to make any desired modifications to your project's "README.md" file, such as adding instructions to tell someone else how to download, setup and run your app. When you're done, make your first commit, with a message like "Setup the repo".
Data Setup
The provided code includes a variable called products
which facilitates management of the products inventory from within the application's source code.
NOTE: If you'd like to use an alternative storage mechanism for the products inventory, like a CSV file or a Google Sheet document, reference the respective further exploration challenges.
Basic Requirements
Write a program that asks the user to input one or more product identifiers, then looks up the prices for each, then prints an itemized customer receipt including the total amount owed.
The program should use one of the provided datastores (see "Data Setup") to represent the store owner's inventory of products and prices.
The program should prompt the checkout clerk to input the identifier of each shopping cart item, one at a time.
When the clerk inputs a product identifier, the program should validate it, displaying a helpful message like "Hey, are you sure that product identifier is correct? Please try again!" if there are no products matching the given identifier.
At any time the clerk should be able to indicate there are no more shopping cart items by inputting the word DONE
or otherwise indicating they are done with the process. Before asking for identifiers, the program should provide clear instructions to the user about how to use the "DONE" keyword.
After the clerk indicates there are no more items, the program should print a custom receipt on the screen. The receipt should include the following components:
A grocery store name of your choice
A grocery store phone number and/or website URL and/or address of choice
The date and time of the beginning of the checkout process, formatted in a human-friendly way (e.g.
2020-02-07 03:54 PM
)The name and price of each shopping cart item, price being formatted as US dollars and cents (e.g.
$3.50
, etc.)The total cost of all shopping cart items (i.e. the "subtotal"), formatted as US dollars and cents (e.g.
$19.47
), calculated as the sum of their pricesThe amount of tax owed (e.g.
$1.70
), calculated by multiplying the total cost by a New York City sales tax rate of 8.75% (for the purposes of this project, groceries are not exempt from sales tax)The total amount owed, formatted as US dollars and cents (e.g.
$21.17
), calculated by adding together the amount of tax owed plus the total cost of all shopping cart itemsA friendly message thanking the customer and/or encouraging the customer to shop again
The program should be able to process multiple shopping cart items of the same kind, but need not display any groupings or aggregations of those items (although it may optionally do so).
Example Output
Feel free but not obligated to follow these guided "checkpoints", which provide one example strategy for breaking-up the requirements into smaller, more manageable pieces.
For a more in-depth guided exercise walkthrough, feel free but not obligated to follow the screencast, but keep in mind a few caveats:
Around minute 50, a "real-time lookups" strategy is changed to a "lookup later" strategy, but either is fine!
Some of the links reference a previous course repository, but you should be able to find related documents in this course repository as well
If there is any discrepancy between requirements referenced in the video and requirements stated in this document, defer to the requirements stated in this document
If you are able to implement the basic requirements with relative ease, consider addressing one or more of these "Further Exploration Challenges" to enrich and expand your learning experience.
Evaluation
Project submissions will be evaluated according to the requirements set forth above, as summarized by the rubric below:
Category
Requirement
Weight
Repository
Includes README.md file with detailed instructions, including specific python
run command. If requiring third-party packages, must specify conda
environment management commands and pip
installation commands in conjunction with a "requirements.txt" file approach. If using environment variables, must use a secure ".env" file approach.
12%
Info Inputs
Captures / scans product identifiers.
8%
Info Inputs
Handles invalid inputs, fails gracefully on invalid product lookups.
10%
Info Inputs
Instructs the user about, and handles, the "DONE" signal.
10%
Info Outputs (Receipt)
Displays store info.
8%
Info Outputs (Receipt)
Displays checkout date and time, in a human-friendly format.
10%
Info Outputs (Receipt)
Displays names and prices of all scanned products.
15%
Info Outputs (Receipt)
Displays tax and totals.
15%
Dev Process
Submitted via Git repository which reflects an incremental revision history.
12%
If experiencing execution error(s) while evaluating the application's required functionality, evaluators are advised to reduce the project's grade by between 4% and 25%, depending on the circumstances and severity of the error(s).
In recognition of deliverables which exhibit functionality above and beyond the basic requirements, evaluators are encouraged to award between 4% and 15% "engagement points" to be applied as extra credit.
Last updated