8a - Use Lists, string manipulation, functions, iteration and more to complete this ONLINE SHOPPING (Create Basket and Checkout) Program
An online store stores a list of their products (with Item ID and Cost) in a list. They want a demo program that allows customers to browse products, add to basket, and then checkout and produce a total £ of what is in their basket. The checkout feature is not expressly mentioned in the task, but this is an essential skill that you would do well to learn at this stage!
Challenge - use lists, string manipulation, functions, iteration and more to solve this challenge.
First, watch the demo video below. Your task is to code something like this, and use the code below to get started
You can either edit and code online in repl.it or you can simply cut and paste the below into your own python file
#Task - first test the program by inputting "001"#Add 5 more products with details to the list#Create a main menu that allows a customer to 1. Browse Products 2. View Basket #Note: Add the products selected (for viewing) by the user to another list called "basket"#print the basket in the "View Basket" sub#this is a list that contains product informaton
product = ["001", "iphone", "£900", "002", "samsung", "£1020", "003", "toshiba", "£700"]
#stores whether the product has been found
found=False#asks the user to enter a product code
product_code=input("Enter the product code of the item: ")
#a loop that will repeat for the length of the listfor x inrange(0,len(product)):
#checks if the product code entered matches the current element of the list being checkedif product[x] == product_code:
#if it is it prints the name and costprint(product[x +1])
#sets found to true as the product is found
found =True#after the loop checks if the product was not foundif found==False:
#if it wasn't found it says product not foundprint("Product not found")
Code your solution here
Systems Life Cycle (in a nutshell): Analyse - Design - Create - Test - Evaluate.
Designing something or writing out some pseudocode before you actually write code is always a good idea! Get in to the habit of doing so! You can draw your flowchart here and screenshot it.
A sample flow chart (design) for this particular challenge could look like:
Each challenge section below provides an online drawing tool where you can dynamically create flowcharts. Screenshot them into your presentation for submission.
Solutions & Answers
Answers /Solutions in the "members area" drive under: "Solve and Learn >>SOLUTIONS"
You may want to read a little about Testing first. A teacher may go through some examples with you. Feel free to fill in the test table here, and screenshot it in to your powerpoint.
Testing is absolutely essential once you have created a program!