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!
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 list for x in range(0,len(product)): #checks if the product code entered matches the current element of the list being checked if product[x] == product_code: #if it is it prints the name and cost print(product[x + 1]) print(product[x + 2]) #sets found to true as the product is found found = True #after the loop checks if the product was not found if found==False: #if it wasn't found it says product not found print("Product not found")
A sample flow chart (design) for this particular challenge could look like:
Test No. | Description | Test Data(input) | Expected Outcome | Actual Outcome | Further Action? |
---|---|---|---|---|---|
1 | |||||
2 | |||||
3 | |||||
4 | |||||
5 |